Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Head
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
1
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 */
14namespace Pop\Pdf\Build\Font\TrueType\Table;
15
16/**
17 * HEAD 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 */
26class Head extends AbstractTable
27{
28
29    /**
30     * Font table properties
31     * @var array
32     */
33    protected array $properties = [];
34
35    /**
36     * Constructor
37     *
38     * Instantiate a TTF 'head' table object.
39     *
40     * @param  \Pop\Pdf\Build\Font\TrueType $font
41     */
42    public function __construct(\Pop\Pdf\Build\Font\TrueType $font)
43    {
44        $bytePos = $font->tableInfo['head']->offset;
45
46        $tableVersionNumberBytes = $font->read($bytePos, 4);
47        $tableVersionNumber      = $font->readFixed(16, 16, $tableVersionNumberBytes);
48
49        $bytePos += 4;
50
51        $fontRevisionBytes = $font->read($bytePos, 4);
52        $fontRevision      = $font->readFixed(16, 16, $fontRevisionBytes);
53
54        $versionArray = [
55            'tableVersionNumber' => $tableVersionNumber,
56            'fontRevision'       => $fontRevision
57        ];
58
59        $bytePos += 4;
60
61        $headerArray = unpack(
62            'NcheckSumAdjustment/' .
63            'NmagicNumber/' .
64            'nflags/' .
65            'nunitsPerEm', $font->read($bytePos, 12)
66        );
67
68        $bytePos += 28;
69        $bBox = unpack(
70            'nxMin/' .
71            'nyMin/' .
72            'nxMax/' .
73            'nyMax', $font->read($bytePos, 8)
74        );
75        $bBox = $font->shiftToSigned($bBox);
76
77        $bytePos += 14;
78        $indexToLocFormat = unpack('nindexToLocFormat', $font->read($bytePos, 2));
79        $headerArray['indexToLocFormat'] = $font->shiftToSigned($indexToLocFormat['indexToLocFormat']);
80
81        $this->properties = array_merge($versionArray, $headerArray, $bBox);
82    }
83
84}