From a0a02efe487cc39bd5223359e916dbeafb5cd6fe Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 23 Dec 2024 12:43:22 +0000 Subject: [PATCH] Add some addTTFfont fixes from tc-lib-pdf-font --- CHANGELOG.TXT | 1 + include/tcpdf_fonts.php | 43 +++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 0eba0b2e..9262c5ba 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -3,6 +3,7 @@ - Escape error message. - Use strict time-constant function to compare TCPDF-tag hashes. - Add K_CURLOPTS config array to set custom cURL options (NOTE: some defaults have changed). + - Add some addTTFfont fixes from tc-lib-pdf-font. 6.7.8 (2024-12-13) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index f4518d9e..4973b285 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1,13 +1,13 @@ 0) { + if (preg_match_all('#dup[\s]([0-9]+)[\s]*+/([^\s]*+)[\s]put#sU', $font, $fmap, PREG_SET_ORDER) > 0) { foreach ($fmap as $v) { $imap[$v[2]] = $v[1]; } @@ -229,22 +230,22 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ $eplain .= chr($chr ^ ($r >> 8)); $r = ((($chr + $r) * $c1 + $c2) % 65536); } - if (preg_match('#/ForceBold[\s]*([^\s]*)#', $eplain, $matches) > 0) { + if (preg_match('#/ForceBold[\s]*+([^\s]*+)#', $eplain, $matches) > 0) { if ($matches[1] == 'true') { $fmetric['Flags'] |= 0x40000; } } - if (preg_match('#/StdVW[\s]*\[([^\]]*)#', $eplain, $matches) > 0) { + if (preg_match('#/StdVW[\s]*+\[([^\]]*+)#', $eplain, $matches) > 0) { $fmetric['StemV'] = intval($matches[1]); } else { $fmetric['StemV'] = 70; } - if (preg_match('#/StdHW[\s]*\[([^\]]*)#', $eplain, $matches) > 0) { + if (preg_match('#/StdHW[\s]*+\[([^\]]*+)#', $eplain, $matches) > 0) { $fmetric['StemH'] = intval($matches[1]); } else { $fmetric['StemH'] = 30; } - if (preg_match('#/BlueValues[\s]*\[([^\]]*)#', $eplain, $matches) > 0) { + if (preg_match('#/BlueValues[\s]*+\[([^\]]*+)#', $eplain, $matches) > 0) { $bv = explode(' ', $matches[1]); if (count($bv) >= 6) { $v1 = intval($bv[2]); @@ -265,7 +266,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ $fmetric['CapHeight'] = 700; } // get the number of random bytes at the beginning of charstrings - if (preg_match('#/lenIV[\s]*([0-9]*)#', $eplain, $matches) > 0) { + if (preg_match('#/lenIV[\s]*+([\d]*+)#', $eplain, $matches) > 0) { $lenIV = intval($matches[1]); } else { $lenIV = 4; @@ -273,7 +274,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ $fmetric['Leading'] = 0; // get charstring data $eplain = substr($eplain, (strpos($eplain, '/CharStrings') + 1)); - preg_match_all('#/([A-Za-z0-9\.]*)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', $eplain, $matches, PREG_SET_ORDER); + preg_match_all('#/([A-Za-z0-9\.]*+)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', $eplain, $matches, PREG_SET_ORDER); if (!empty($enc) AND isset(TCPDF_FONT_DATA::$encmap[$enc])) { $enc_map = TCPDF_FONT_DATA::$encmap[$enc]; } else {