Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
AbstractStandard | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
4.25 | |
0.00% |
0 / 1 |
getUnitsPerEm | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getGlyphWidth | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
3.33 |
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\Standard; |
15 | |
16 | /** |
17 | * Pdf abstract standard font 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 | abstract class AbstractStandard |
27 | { |
28 | |
29 | /** |
30 | * Font units per em |
31 | * @var int |
32 | */ |
33 | protected int $unitsPerEm = 1000; |
34 | |
35 | /** |
36 | * Font glyph widths |
37 | * @var array |
38 | */ |
39 | protected array $glyphWidths = []; |
40 | |
41 | /** |
42 | * Font character map |
43 | * @var array |
44 | */ |
45 | protected array $cmap = []; |
46 | |
47 | /** |
48 | * Get units per em |
49 | * |
50 | * @return int |
51 | */ |
52 | public function getUnitsPerEm(): int |
53 | { |
54 | return $this->unitsPerEm; |
55 | } |
56 | |
57 | /** |
58 | * Get character glyph width |
59 | * |
60 | * @param int $code |
61 | * @return mixed |
62 | */ |
63 | public function getGlyphWidth(int $code): mixed |
64 | { |
65 | if (isset($this->cmap[$code]) && isset($this->glyphWidths[$this->cmap[$code]])) { |
66 | return $this->glyphWidths[$this->cmap[$code]]; |
67 | } else { |
68 | return 0; |
69 | } |
70 | } |
71 | |
72 | } |