Skip to content

Commit a5c4d40

Browse files
author
Indrek Altpere
committed
Use the read-many helper, handle uint16 => int16 conversion inline because there is no other way to optimize this
1 parent 9e032d9 commit a5c4d40

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/FontLib/Table/Type/kern.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ protected function _parse() {
4444
$pairs = array();
4545
$tree = array();
4646

47-
for ($i = 0; $i < $subtable["nPairs"]; $i++) {
48-
$left = $font->readUInt16();
49-
$right = $font->readUInt16();
50-
$value = $font->readInt16();
47+
$values = $font->readUInt16Many($subtable["nPairs"] * 3);
48+
for ($i = 0, $idx = 0; $i < $subtable["nPairs"]; $i++) {
49+
$left = $values[$idx++];
50+
$right = $values[$idx++];
51+
$value = $values[$idx++];
52+
53+
if ($value >= 0x8000) {
54+
$value -= 0x10000;
55+
}
5156

5257
$pairs[] = array(
5358
"left" => $left,

0 commit comments

Comments
 (0)