Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Mar 25, 2024
1 parent af272b8 commit 2c3d167
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.1
2 changes: 1 addition & 1 deletion src/Load.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ protected function findFontDirectories(): array
}

$parent_font_dir = $dir->findParentDir('fonts', __DIR__);
if ($parent_font_dir !== '') {
if (($parent_font_dir !== '') && ($parent_font_dir !== '/')) {
$dirs[] = $parent_font_dir;
$glb = glob($parent_font_dir . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
if ($glb !== false) {
Expand Down
6 changes: 3 additions & 3 deletions src/OutFont.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,16 @@ protected function getTrueTypeUnicode(array $font): string
. '<<';
$cidhmap = Identity::CIDHMAP;
if ($font['compress']) {
$out .= '/Filter /FlateDecode';
$out .= ' /Filter /FlateDecode';
$cidhmap = gzcompress($cidhmap);
if ($cidhmap === false) {
throw new \RuntimeException('Unable to compress CIDHMAP');
}
}

$stream = $this->enc->encryptString($cidhmap, $this->pon); // ToUnicode map for Identity-H
$out .= '/Length ' . strlen($stream)
. '>>'
$out .= ' /Length ' . strlen($stream)
. ' >>'
. ' stream' . "\n"
. $stream . "\n"
. 'endstream' . "\n"
Expand Down
12 changes: 6 additions & 6 deletions src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ public function getOrdArrDims(array $uniarr): array
$totwidth = 0; // total string width
$totspacewidth = 0; // total space width
$words = 0; // total number of words
$spw = $this->getCharWidth(32); // width of a single space
$fact = ($this->stack[$this->index]['spacing'] * $this->stack[$this->index]['stretching']);
$uniarr[] = 8203; // add null at the end to ensure that the last word is processed
$split = [];
foreach ($uniarr as $idx => $ord) {
$unitype = UnicodeType::UNI[$ord];
$chrwidth = $this->getCharWidth($ord);
// 'B' Paragraph Separator
// 'S' Segment Separator
// 'WS' Whitespace
Expand All @@ -379,12 +379,12 @@ public function getOrdArrDims(array $uniarr): array
$split[$words]['wordwidth'] = ($split[$words]['totwidth'] - $split[($words - 1)]['totwidth']);
}
$words++;
if ($unitype == 'WS') {
++$spaces;
$totspacewidth += $chrwidth;
}
}
if ($ord == 32) {
++$spaces;
$totspacewidth += $spw;
}
$totwidth += $this->getCharWidth($ord);
$totwidth += $chrwidth;
}
$totwidth += ($fact * ($chars - 1));
$totspacewidth += ($fact * ($spaces - 1));
Expand Down

0 comments on commit 2c3d167

Please sign in to comment.