Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Loca | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
5 | |||
| 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-2026 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 | * LOCA table class |
| 18 | * |
| 19 | * @category Pop |
| 20 | * @package Pop\Pdf |
| 21 | * @author Nick Sagona, III <dev@noladev.com> |
| 22 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 23 | * @license https://www.popphp.org/license New BSD License |
| 24 | * @version 5.2.7 |
| 25 | */ |
| 26 | class Loca extends AbstractTable |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Font table properties |
| 31 | * @var array |
| 32 | */ |
| 33 | protected array $properties = [ |
| 34 | 'offsets' => [] |
| 35 | ]; |
| 36 | |
| 37 | /** |
| 38 | * Constructor |
| 39 | * |
| 40 | * Instantiate a TTF 'loca' 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['loca']->offset; |
| 47 | $format = ($font->header->indexToLocFormat == 1) ? 'N' : 'n'; |
| 48 | $byteLength = ($font->header->indexToLocFormat == 1) ? 4 : 2; |
| 49 | $multiplier = ($font->header->indexToLocFormat == 1) ? 1 : 2; |
| 50 | |
| 51 | for ($i = 0; $i < ($font->numberOfGlyphs + 1); $i++) { |
| 52 | $ary = unpack($format . 'offset', $font->read($bytePos, $byteLength)); |
| 53 | $this->properties['offsets'][$i] = $ary['offset'] * $multiplier; |
| 54 | $bytePos += $byteLength; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | } |