Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/FontLib/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function load($file) {
}

if ($class) {
$class = "FontLib\\$class";
$class = __NAMESPACE__ . "\\$class";

/** @var TrueType\File $obj */
$obj = new $class;
Expand Down
21 changes: 10 additions & 11 deletions src/FontLib/TrueType/File.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does strauss automatically handle namespace references in use statements? What about the strings containing \FontLib\Table\... references around line 400 in this file?

Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function getUnicodeCharMap() {
return $glyphIndexArray;
}
}

return null;
}

Expand Down Expand Up @@ -380,11 +380,6 @@ function parseHeader() {
$this->header->parse();
}

function getFontType(){
$class_parts = explode("\\", get_class($this));
return $class_parts[1];
}

function parseTableEntries() {
$this->parseHeader();

Expand All @@ -396,9 +391,7 @@ function parseTableEntries() {
return;
}


$type = $this->getFontType();
$class = "FontLib\\$type\\TableDirectoryEntry";
$class = __NAMESPACE__ . "\\TableDirectoryEntry";

for ($i = 0; $i < $this->header->data["numTables"]; $i++) {
/** @var TableDirectoryEntry $entry */
Expand All @@ -413,20 +406,26 @@ function normalizeFUnit($value, $base = 1000) {
return round($value * ($base / $this->getData("head", "unitsPerEm")));
}

private function tableClass(string $name_canon): string {
$root = __NAMESPACE__;
$root = substr($root, 0, strrpos($root, '\\'));
return $root . '\\Table\\Type\\' . $name_canon;
}

protected function readTable($tag) {
$this->parseTableEntries();

if (!self::$raw) {
$name_canon = preg_replace("/[^a-z0-9]/", "", strtolower($tag));

$class = "FontLib\\Table\\Type\\$name_canon";
$class = $this->tableClass($name_canon);

if (!isset($this->directory[$tag]) || !@class_exists($class)) {
return;
}
}
else {
$class = "FontLib\\Table\\Table";
$class = Table::class;
}

/** @var Table $table */
Expand Down