Skip to content

Commit

Permalink
Add height and midpoint metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Nov 2, 2023
1 parent 729dadb commit ada555d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.12
1.16.1
2 changes: 2 additions & 0 deletions src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ protected function getFontMetric($font)
'dw' => ($data['dw'] * $cratio * $font['stretching']),
'ascent' => ($data['desc']['Ascent'] * $cratio),
'descent' => ($data['desc']['Descent'] * $cratio),
'height' => (($data['desc']['Ascent'] - $data['desc']['Descent']) * $cratio),
'midpoint' => (($data['desc']['Ascent'] + $data['desc']['Descent']) * $cratio / 2),
'capheight' => ($data['desc']['CapHeight'] * $cratio),
'xheight' => ($data['desc']['XHeight'] * $cratio),
'avgwidth' => ($data['desc']['AvgWidth'] * $cratio * $font['stretching']),
Expand Down
2 changes: 2 additions & 0 deletions test/StackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function testStack()
$this->bcAssertEqualsWithDelta(4.6704, $bfont['dw'], 0.0001);
$this->bcAssertEqualsWithDelta(13.342, $bfont['ascent'], 0.0001);
$this->bcAssertEqualsWithDelta(-3.08, $bfont['descent'], 0.0001);
$this->bcAssertEqualsWithDelta(16.422, $bfont['height'], 0.0001);
$this->bcAssertEqualsWithDelta(5.131, $bfont['midpoint'], 0.0001);
$this->bcAssertEqualsWithDelta(10.136, $bfont['capheight'], 0.0001);
$this->bcAssertEqualsWithDelta(7.56, $bfont['xheight'], 0.0001);
$this->bcAssertEqualsWithDelta(9.492, $bfont['avgwidth'], 0.0001);
Expand Down

0 comments on commit ada555d

Please sign in to comment.