Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/tcpdf_fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'];
}

Expand Down Expand Up @@ -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;
}

Expand Down