diff --git a/src/FontLib/BinaryStream.php b/src/FontLib/BinaryStream.php index 2b6b7eb..c305109 100644 --- a/src/FontLib/BinaryStream.php +++ b/src/FontLib/BinaryStream.php @@ -210,7 +210,8 @@ public function writeUFWord($data) { } public function readInt16() { - $v = $this->readUInt16(); + $a = unpack("nn", $this->read(2)); + $v = $a["n"]; if ($v >= 0x8000) { $v -= 0x10000; diff --git a/src/FontLib/Glyph/Outline.php b/src/FontLib/Glyph/Outline.php index 12091a9..330db09 100644 --- a/src/FontLib/Glyph/Outline.php +++ b/src/FontLib/Glyph/Outline.php @@ -42,8 +42,7 @@ class Outline extends BinaryStream { * * @return Outline */ - static function init(glyf $table, $offset, $size) { - $font = $table->getFont(); + static function init(glyf $table, $offset, $size, BinaryStream $font) { $font->seek($offset); if ($font->readInt16() > -1) { @@ -55,7 +54,7 @@ static function init(glyf $table, $offset, $size) { $glyph = new OutlineComposite($table, $offset, $size); } - $glyph->parse(); + $glyph->parse($font); return $glyph; } @@ -73,8 +72,7 @@ function __construct(glyf $table, $offset = null, $size = null) { $this->size = $size; } - function parse() { - $font = $this->getFont(); + function parse(BinaryStream $font) { $font->seek($this->offset); if (!$this->size) { diff --git a/src/FontLib/Table/Type/glyf.php b/src/FontLib/Table/Type/glyf.php index cbc04d2..1fbec3f 100644 --- a/src/FontLib/Table/Type/glyf.php +++ b/src/FontLib/Table/Type/glyf.php @@ -31,7 +31,7 @@ protected function _parse() { foreach ($real_loca as $gid => $location) { $_offset = $offset + $loca[$gid]; $_size = $loca[$gid + 1] - $loca[$gid]; - $data[$gid] = Outline::init($this, $_offset, $_size); + $data[$gid] = Outline::init($this, $_offset, $_size, $font); } $this->data = $data;