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