From fe94384d4066186a28a34535f4e331ae19ac9287 Mon Sep 17 00:00:00 2001 From: Renan Rodrigo Date: Wed, 25 Feb 2026 11:54:07 -0300 Subject: [PATCH] Ignore warnings about float to int casting on tcpdf_fonts The warning is being thrown in PHP 8.5, and it's breaking PDF generation in some cases, caught in tests executed on armhf systems. Fixes: #856 --- include/tcpdf_fonts.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index fbe7009c..d1e5debe 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -930,6 +930,12 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ * @public static */ public static function _getTTFtableChecksum($table, $length) { + // Suppress warning about casting on armhf + if (PHP_INT_SIZE == 4) { + set_error_handler(function($errno, $errstr) { + return strpos($errstr, 'is not representable as an int') !== false; + }, E_WARNING); + } $sum = 0; $tlen = ($length / 4); $offset = 0; @@ -939,6 +945,9 @@ public static function _getTTFtableChecksum($table, $length) { $offset += 4; } $sum = unpack('Ni', pack('N', $sum)); + if (PHP_INT_SIZE == 4) { + restore_error_handler(); + } return $sum['i']; } @@ -1382,9 +1391,18 @@ public static function _getTrueTypeFontSubset($font, $subsetchars) { foreach ($table as $data) { $font .= $data['data']; } + // Suppress warning about casting on armhf + if (PHP_INT_SIZE == 4) { + set_error_handler(function($errno, $errstr) { + return strpos($errstr, 'is not representable as an int') !== false; + }, E_WARNING); + } // set checkSumAdjustment on head table $checkSumAdjustment = 0xB1B0AFBA - self::_getTTFtableChecksum($font, strlen($font)); $font = substr($font, 0, $table['head']['offset'] + $offset + 8).pack('N', $checkSumAdjustment).substr($font, $table['head']['offset'] + $offset + 12); + if (PHP_INT_SIZE == 4) { + restore_error_handler(); + } return $font; }