1 | <?php |
||
29 | class FontMeta |
||
30 | { |
||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $fileName; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $data = array( |
||
40 | 'copyright' => null, |
||
41 | 'fontFamily' => null, |
||
42 | 'fontSubFamily' => null, |
||
43 | 'fontIdentifier' => null, |
||
44 | 'fontName' => null, |
||
45 | 'fontVersion' => null, |
||
46 | 'postscriptName' => null, |
||
47 | 'trademark' => null, |
||
48 | 'manufacturerName' => null, |
||
49 | 'designer' => null, |
||
50 | 'description' => null, |
||
51 | 'vendorUrl' => null, |
||
52 | 'designerUrl' => null, |
||
53 | 'licenseDescription' => null, |
||
54 | 'licenseUrl' => null, |
||
55 | 'reservedField' => null, |
||
56 | 'preferredFamily' => null, |
||
57 | 'preferredSubFamily' => null, |
||
58 | 'compatibleFullName' => null, |
||
59 | 'postscriptCid' => null, |
||
60 | ); |
||
61 | |||
62 | /** |
||
63 | * FontMeta constructor. |
||
64 | * |
||
65 | * @param string $fileName |
||
66 | * @throws \Exception |
||
67 | */ |
||
68 | function __construct($fileName) |
||
77 | |||
78 | /** |
||
79 | * @param string $name |
||
80 | * @param array $args |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function __call($name, $args) |
||
88 | |||
89 | /** |
||
90 | * Read the font Metadata |
||
91 | * |
||
92 | * @throws \Exception |
||
93 | */ |
||
94 | public function readFontMetadata() |
||
112 | |||
113 | /** |
||
114 | * @param resource $fontHandle |
||
115 | * |
||
116 | * @return int |
||
117 | * @throws \Exception |
||
118 | */ |
||
119 | private function getNameTableOffset($fontHandle) |
||
134 | |||
135 | /** |
||
136 | * @param resource $fontHandle |
||
137 | * @param int $offset |
||
138 | * @param int $storageOffset |
||
139 | */ |
||
140 | private function findAndExtractCandidate($fontHandle, $offset, $storageOffset) |
||
159 | |||
160 | /** |
||
161 | * Extract possible property/attribute. $data keys are |
||
162 | * intentionally sorted in order of the font file table. |
||
163 | * |
||
164 | * @param int $nameId |
||
165 | * @param string $testValue |
||
166 | */ |
||
167 | private function extractCandidate($nameId, $testValue) |
||
174 | |||
175 | /** |
||
176 | * Remove ASCII ctrl characters |
||
177 | * |
||
178 | * @param string $value |
||
179 | * @return string |
||
180 | */ |
||
181 | private function cleanupValue($value) |
||
185 | |||
186 | /** |
||
187 | * Convert big endian unsigned short[n] or long[N] value to an integer. |
||
188 | * |
||
189 | * @param string $value |
||
190 | * @param string $format |
||
191 | * @return int |
||
192 | */ |
||
193 | private function unpack($value, $format = 'n') |
||
198 | } |
||
199 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.