From 9e8861b4dc124c020ff63ab944cdba1ed22ccd65 Mon Sep 17 00:00:00 2001 From: Przemek Peron <przemek@redkorn.pl> Date: Thu, 1 Oct 2020 20:27:02 +0200 Subject: [PATCH 1/6] Fix for PHP 7.4 --- tcpdf.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcpdf.php b/tcpdf.php index 8b7d812..1ce3838 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -6866,6 +6866,12 @@ class TCPDF { list($x, $y) = $this->checkPageRegions($h, $x, $y); $exurl = ''; // external streams $imsize = FALSE; + + // Make sure the file variable is not empty or null because accessing $file[0] later + // results in error when running PHP 7.4 + if (empty($file)) { + return false; + } // check if we are passing an image as file or string if ($file[0] === '@') { // image from string From e5f4da5a76b44cd94740a5d293ae5558d5cb5443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= <cedric.anne@gmail.com> Date: Wed, 14 Oct 2020 10:33:59 +0200 Subject: [PATCH 2/6] Fix optionnal "$currentfont" parameter declaration --- include/tcpdf_fonts.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 218fb6d..4f5bcf3 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1995,7 +1995,7 @@ class TCPDF_FONTS { * @author Nicola Asuni * @public static */ - public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) { + public static function UTF8StringToArray($str, $isunicode=true, &$currentfont=array()) { if ($isunicode) { // requires PCRE unicode support turned on $chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY); @@ -2021,7 +2021,7 @@ class TCPDF_FONTS { * @since 3.2.000 (2008-06-23) * @public static */ - public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont) { + public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont=array()) { $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values return self::UTF8ArrToLatin1($unicode); } @@ -2037,7 +2037,7 @@ class TCPDF_FONTS { * @since 1.53.0.TC005 (2005-01-05) * @public static */ - public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont) { + public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont=array()) { if (!$isunicode) { return $str; // string is not in unicode } @@ -2057,7 +2057,7 @@ class TCPDF_FONTS { * @since 2.1.000 (2008-01-08) * @public static */ - public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont); } @@ -2074,7 +2074,7 @@ class TCPDF_FONTS { * @since 4.9.000 (2010-03-27) * @public static */ - public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str, $forcertl, $isunicode, $currentfont), $setbom); } @@ -2090,7 +2090,7 @@ class TCPDF_FONTS { * @since 2.4.000 (2008-03-06) * @public static */ - public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont=array()) { // paragraph embedding level $pel = 0; // max level From 292fc741f82f68283fd2d8171fc1ae92ff15b946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= <cedric.anne@gmail.com> Date: Wed, 14 Oct 2020 10:35:08 +0200 Subject: [PATCH 3/6] Fix optionnal "$k" parameter declaration --- include/tcpdf_static.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 06a1ddd..56af4a0 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -2507,7 +2507,7 @@ class TCPDF_STATIC { * @since 5.0.010 (2010-05-17) * @public static */ - public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) { + public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k=1, $pagedim=array()) { if (!isset($pagedim[$page])) { // initialize array $pagedim[$page] = array(); From 9616e9e44b111e79f6931763da265f05638aa839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= <cedric.anne@gmail.com> Date: Wed, 14 Oct 2020 10:35:46 +0200 Subject: [PATCH 4/6] Fix optionnal "$tagvspaces" parameter declaration --- include/tcpdf_static.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 56af4a0..56ea082 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -1136,7 +1136,7 @@ class TCPDF_STATIC { * @see setHtmlVSpace() * @public static */ - public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) { + public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces=array()) { // configure parameters for HTML Tidy if ($tidy_options === '') { $tidy_options = array ( From 481e46d365cc03f81a8869e2639004ca00210de7 Mon Sep 17 00:00:00 2001 From: Yuya Yabe <dev@nullx2.com> Date: Wed, 11 Nov 2020 15:44:33 +0900 Subject: [PATCH 5/6] Fix width calc --- tcpdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcpdf.php b/tcpdf.php index 8b7d812..2f30216 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -6489,7 +6489,7 @@ class TCPDF { // *** very slow *** $l = $this->GetArrStringWidth(TCPDF_FONTS::utf8Bidi(array_slice($chars, $j, ($i - $j)), '', $this->tmprtl, $this->isunicode, $this->CurrentFont)); } else { - $l += $this->GetCharWidth($c); + $l += $this->GetCharWidth($c, ($i+1 < $nb)); } if (($l > $wmax) OR (($c == 173) AND (($l + $tmp_shy_replacement_width) >= $wmax))) { if (($c == 173) AND (($l + $tmp_shy_replacement_width) > $wmax)) { From b1d592252550a924cd39f179c0293a43fce71801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= <mvorisek@mvorisek.cz> Date: Mon, 23 Nov 2020 10:57:57 +0100 Subject: [PATCH 6/6] Fix EOL of text files --- fonts/freefont-20100919/CREDITS | 2 +- fonts/freefont-20120503/CREDITS | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fonts/freefont-20100919/CREDITS b/fonts/freefont-20100919/CREDITS index 66396e7..0b69784 100644 --- a/fonts/freefont-20100919/CREDITS +++ b/fonts/freefont-20100919/CREDITS @@ -352,7 +352,7 @@ please contact mssridhar AT vsnl.com. Noah Levitt found out that the Sinhalese fonts available on the site <http://www.metta.lk/fonts/> are released under GNU GPL, or, -precisely, "Public Domain under GNU Licence Produced by DMS +precisely, "Public Domain under GNU Licence Produced by DMS Electronics for The Sri Lanka Tipitaka Project" (taken from the font comment), and took the effort of recoding the font to Unicode. diff --git a/fonts/freefont-20120503/CREDITS b/fonts/freefont-20120503/CREDITS index 06d280e..f4430ec 100644 --- a/fonts/freefont-20120503/CREDITS +++ b/fonts/freefont-20120503/CREDITS @@ -357,7 +357,7 @@ please contact mssridhar AT vsnl.com. Noah Levitt found out that the Sinhalese fonts available on the site <http://www.metta.lk/fonts/> are released under GNU GPL, or, -precisely, "Public Domain under GNU Licence Produced by DMS +precisely, "Public Domain under GNU Licence Produced by DMS Electronics for The Sri Lanka Tipitaka Project" (taken from the font comment), and took the effort of recoding the font to Unicode.