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