3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
9 namespace FontLib\Table\Type
;
10 use FontLib\Table\Table
;
11 use FontLib\TrueType\File
;
16 * @package php-font-lib
18 class post
extends Table
{
19 protected $def = array(
20 "format" => self
::Fixed
,
21 "italicAngle" => self
::Fixed
,
22 "underlinePosition" => self
::FWord
,
23 "underlineThickness" => self
::FWord
,
24 "isFixedPitch" => self
::uint32
,
25 "minMemType42" => self
::uint32
,
26 "maxMemType42" => self
::uint32
,
27 "minMemType1" => self
::uint32
,
28 "maxMemType1" => self
::uint32
,
31 protected function _parse() {
32 $font = $this->getFont();
33 $data = $font->unpack($this->def
);
37 switch ($data["format"]) {
39 $names = File
::$macCharNames;
43 $data["numberOfGlyphs"] = $font->readUInt16();
45 $glyphNameIndex = array();
46 for ($i = 0; $i < $data["numberOfGlyphs"]; $i++
) {
47 $glyphNameIndex[] = $font->readUInt16();
50 $data["glyphNameIndex"] = $glyphNameIndex;
52 $namesPascal = array();
53 for ($i = 0; $i < $data["numberOfGlyphs"]; $i++
) {
54 $len = $font->readUInt8();
55 $namesPascal[] = $font->read($len);
58 foreach ($glyphNameIndex as $g => $index) {
60 $names[$g] = File
::$macCharNames[$index];
63 $names[$g] = $namesPascal[$index - 258];
82 $data["names"] = $names;
88 $font = $this->getFont();
92 $length = $font->pack($this->def
, $data);
96 $subset = $font->getSubset();
98 switch($data["format"]) {
104 $old_names = $data["names"];
106 $glyphNameIndex = range(0, count($subset));
109 foreach($subset as $gid) {
110 $names[] = $data["names"][$data["glyphNameIndex"][$gid]];
113 $numberOfGlyphs = count($names);
114 $length += $font->writeUInt16($numberOfGlyphs);
116 foreach($glyphNameIndex as $gni) {
117 $length += $font->writeUInt16($gni);
120 //$names = array_slice($names, 257);
121 foreach($names as $name) {
122 $len = strlen($name);
123 $length += $font->writeUInt8($len);
124 $length += $font->write($name, $len);