Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| AfmData | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\FontMetrics; |
| 6 | |
| 7 | final class AfmData |
| 8 | { |
| 9 | /** |
| 10 | * @param array<string,int> $widths Glyph name => width in 1/1000 em |
| 11 | * @param array{float,float,float,float} $fontBBox [llx,lly,urx,ury] |
| 12 | */ |
| 13 | public function __construct( |
| 14 | public readonly float $ascender, |
| 15 | public readonly float $descender, |
| 16 | public readonly float $capHeight, |
| 17 | public readonly float $xHeight, |
| 18 | public readonly float $italicAngle, |
| 19 | public readonly float $stemV, |
| 20 | public readonly float $missingWidth, |
| 21 | public readonly array $fontBBox, |
| 22 | public readonly array $widths, |
| 23 | ) {} |
| 24 | |
| 25 | public function getWidth(string $glyphName): int |
| 26 | { |
| 27 | return $this->widths[$glyphName] ?? (int) $this->missingWidth; |
| 28 | } |
| 29 | } |