Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Hhea | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Pdf\Build\Font\TrueType\Table; |
| 15 | |
| 16 | /** |
| 17 | * HHEA table class |
| 18 | * |
| 19 | * @category Pop |
| 20 | * @package Pop\Pdf |
| 21 | * @author Nick Sagona, III <dev@noladev.com> |
| 22 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
| 23 | * @license https://www.popphp.org/license New BSD License |
| 24 | * @version 5.2.2 |
| 25 | */ |
| 26 | class Hhea extends AbstractTable |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Font table properties |
| 31 | * @var array |
| 32 | */ |
| 33 | protected array $properties = [ |
| 34 | 'ascent' => 0, |
| 35 | 'descent' => 0, |
| 36 | 'numberOfHMetrics' => 0 |
| 37 | ]; |
| 38 | |
| 39 | /** |
| 40 | * Constructor |
| 41 | * |
| 42 | * Instantiate a TTF 'hhea' table object. |
| 43 | * |
| 44 | * @param \Pop\Pdf\Build\Font\TrueType $font |
| 45 | */ |
| 46 | public function __construct(\Pop\Pdf\Build\Font\TrueType $font) |
| 47 | { |
| 48 | $bytePos = $font->tableInfo['hhea']->offset + 4; |
| 49 | |
| 50 | $ary = unpack( |
| 51 | 'nascent/' . |
| 52 | 'ndescent', $font->read($bytePos, 4) |
| 53 | ); |
| 54 | |
| 55 | $ary = $font->shiftToSigned($ary); |
| 56 | $this->properties['ascent'] = $font->toEmSpace($ary['ascent']); |
| 57 | $this->properties['descent'] = $font->toEmSpace($ary['descent']); |
| 58 | |
| 59 | $bytePos = $font->tableInfo['hhea']->offset + 34; |
| 60 | $ary = unpack('nnumberOfHMetrics/', $font->read($bytePos, 2)); |
| 61 | $this->properties['numberOfHMetrics'] = $ary['numberOfHMetrics']; |
| 62 | } |
| 63 | |
| 64 | } |