Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
TrimmedTable | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
parseData | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 |
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\Cmap; |
15 | |
16 | /** |
17 | * CMAP trimmed-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 TrimmedTable |
27 | { |
28 | |
29 | /** |
30 | * Method to parse the Trimmed Table (Format 6) CMAP data |
31 | * |
32 | * @param string $data |
33 | * @return array |
34 | */ |
35 | public static function parseData(string $data): array |
36 | { |
37 | $ary = unpack( |
38 | 'nfirstCode/' . |
39 | 'nentryCount', substr($data, 0, 4) |
40 | ); |
41 | |
42 | $ary['glyphId'] = array(); |
43 | |
44 | $bytePos = 4; |
45 | for ($i = 0; $i < $ary['entryCount']; $i++) { |
46 | $ar = unpack('nglyphIndex', substr($data, $bytePos, 2)); |
47 | $ary['glyphId'][$i] = $ar['glyphIndex']; |
48 | $bytePos += 2; |
49 | } |
50 | |
51 | return $ary; |
52 | } |
53 | |
54 | } |