composer package updates
[openemr.git] / vendor / phenx / php-font-lib / src / FontLib / EOT / Header.php
blob960e36ad93f3624b44cd0631a9be1bbe5ad5082a
1 <?php
2 /**
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
7 */
9 namespace FontLib\EOT;
11 use Exception;
12 use FontLib\Font;
14 /**
15 * TrueType font file header.
17 * @package php-font-lib
19 * @property File $font
21 class Header extends \FontLib\Header {
22 protected $def = array(
23 "format" => self::uint32,
24 "numTables" => self::uint16,
25 "searchRange" => self::uint16,
26 "entrySelector" => self::uint16,
27 "rangeShift" => self::uint16,
30 public function parse() {
31 $font = $this->font;
33 $this->data = $font->unpack(array(
34 "EOTSize" => self::uint32,
35 "FontDataSize" => self::uint32,
36 "Version" => self::uint32,
37 "Flags" => self::uint32,
38 "FontPANOSE" => array(self::uint8, 10),
39 "Charset" => self::uint8,
40 "Italic" => self::uint8,
41 "Weight" => self::uint32,
42 "fsType" => self::uint16,
43 "MagicNumber" => self::uint16,
44 "UnicodeRange1" => self::uint32,
45 "UnicodeRange2" => self::uint32,
46 "UnicodeRange3" => self::uint32,
47 "UnicodeRange4" => self::uint32,
48 "CodePageRange1" => self::uint32,
49 "CodePageRange2" => self::uint32,
50 "CheckSumAdjustment" => self::uint32,
51 "Reserved1" => self::uint32,
52 "Reserved2" => self::uint32,
53 "Reserved3" => self::uint32,
54 "Reserved4" => self::uint32,
55 ));
57 $this->data["Padding1"] = $font->readUInt16();
58 $this->readString("FamilyName");
60 $this->data["Padding2"] = $font->readUInt16();
61 $this->readString("StyleName");
63 $this->data["Padding3"] = $font->readUInt16();
64 $this->readString("VersionName");
66 $this->data["Padding4"] = $font->readUInt16();
67 $this->readString("FullName");
69 switch ($this->data["Version"]) {
70 default:
71 throw new Exception("Unknown EOT version " . $this->data["Version"]);
73 case 0x00010000:
74 // Nothing to do more
75 break;
77 case 0x00020001:
78 $this->data["Padding5"] = $font->readUInt16();
79 $this->readString("RootString");
80 break;
82 case 0x00020002:
83 $this->data["Padding5"] = $font->readUInt16();
84 $this->readString("RootString");
86 $this->data["RootStringCheckSum"] = $font->readUInt32();
87 $this->data["EUDCCodePage"] = $font->readUInt32();
89 $this->data["Padding6"] = $font->readUInt16();
90 $this->readString("Signature");
92 $this->data["EUDCFlags"] = $font->readUInt32();
93 $this->data["EUDCFontSize"] = $font->readUInt32();
94 break;
97 if (!empty($this->data["RootString"])) {
98 $this->data["RootString"] = explode("\0", $this->data["RootString"]);
102 private function readString($name) {
103 $font = $this->font;
104 $size = $font->readUInt16();
106 $this->data["{$name}Size"] = $size;
107 $this->data[$name] = Font::UTF16ToUTF8($font->read($size));
110 public function encode() {
111 //return $this->font->pack($this->def, $this->data);