Skip to content

Commit 482ab8b

Browse files
committed
Merge pull request #36 from efbiaiinzinz/master
Final patch of optimizations, giving additional 20% speedup
2 parents f4e096e + 84f1b65 commit 482ab8b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/FontLib/BinaryStream.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ public function writeUFWord($data) {
210210
}
211211

212212
public function readInt16() {
213-
$v = $this->readUInt16();
213+
$a = unpack("nn", $this->read(2));
214+
$v = $a["n"];
214215

215216
if ($v >= 0x8000) {
216217
$v -= 0x10000;

src/FontLib/Glyph/Outline.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class Outline extends BinaryStream {
4242
*
4343
* @return Outline
4444
*/
45-
static function init(glyf $table, $offset, $size) {
46-
$font = $table->getFont();
45+
static function init(glyf $table, $offset, $size, BinaryStream $font) {
4746
$font->seek($offset);
4847

4948
if ($font->readInt16() > -1) {
@@ -55,7 +54,7 @@ static function init(glyf $table, $offset, $size) {
5554
$glyph = new OutlineComposite($table, $offset, $size);
5655
}
5756

58-
$glyph->parse();
57+
$glyph->parse($font);
5958

6059
return $glyph;
6160
}
@@ -73,8 +72,7 @@ function __construct(glyf $table, $offset = null, $size = null) {
7372
$this->size = $size;
7473
}
7574

76-
function parse() {
77-
$font = $this->getFont();
75+
function parse(BinaryStream $font) {
7876
$font->seek($this->offset);
7977

8078
if (!$this->size) {

src/FontLib/Table/Type/glyf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function _parse() {
3131
foreach ($real_loca as $gid => $location) {
3232
$_offset = $offset + $loca[$gid];
3333
$_size = $loca[$gid + 1] - $loca[$gid];
34-
$data[$gid] = Outline::init($this, $_offset, $_size);
34+
$data[$gid] = Outline::init($this, $_offset, $_size, $font);
3535
}
3636

3737
$this->data = $data;

0 commit comments

Comments
 (0)