Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed Oct 15, 2023
1 parent 0c9b54d commit 8d3e9d2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public function computeWidth(
private function getGlyphHorizontalAdvance(
CompositeCharacter $compositeCharacter
): int {
if (!isset($this->glyphs[$compositeCharacter->toCharacters()])) {
if (!isset($this->glyphs[$compositeCharacter->toChars()])) {
return $this->missingGlyph->horizontalAdvance()
?? $this->horizontalAdvance;
}

return $this->glyphs[$compositeCharacter->toCharacters()]->horizontalAdvance()
return $this->glyphs[$compositeCharacter->toChars()]->horizontalAdvance()
?? $this->horizontalAdvance;
}
}
2 changes: 1 addition & 1 deletion src/Glyph.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(

if ($horizontalAdvance !== null && $horizontalAdvance < 0) {
throw new \InvalidArgumentException(
"Glyph with unicode `{$compositeCharacter->toCharacters()}` has negative horizontal advance",
"Glyph with unicode `{$compositeCharacter->toChars()}` has negative horizontal advance",
);
}
$this->compositeCharacter = $compositeCharacter;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/SimpleXmlSvgFontFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function initFont(
$unicode = strval($fontChildElement[self::ATTRIBUTE_UNICODE]);

if ($unicode !== '') {
$compositeCharacter = CompositeCharacter::ofCharacters($unicode);
$compositeCharacter = CompositeCharacter::ofChars($unicode);
$glyphs[$unicode] = $this->initGlyph($fontChildElement, $compositeCharacter);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/XmlReaderSvgFontFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function parseFile(
$unicode = strval($xml->getAttribute(self::ATTRIBUTE_UNICODE));

if ($unicode !== '') {
$compositeCharacter = CompositeCharacter::ofCharacters($unicode);
$compositeCharacter = CompositeCharacter::ofChars($unicode);
$glyphs[$unicode] = $this->initGlyph($xml, $compositeCharacter);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/SvgFontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testItCanComputeTextWidth(
$this->assertSame(
$expectedWidth,
$font->computeWidth(
CompositeCharacter::ofCharacters($characters),
CompositeCharacter::ofChars($characters),
$fontSize,
$letterSpacing,
),
Expand Down

0 comments on commit 8d3e9d2

Please sign in to comment.