Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / phenx / php-font-lib / src / FontLib / EOT / File.php
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  */
8
9 namespace FontLib\EOT;
10
11 /**
12  * EOT font file.
13  *
14  * @package php-font-lib
15  */
16 class File extends \FontLib\TrueType\File {
17   const TTEMBED_SUBSET                   = 0x00000001;
18   const TTEMBED_TTCOMPRESSED             = 0x00000004;
19   const TTEMBED_FAILIFVARIATIONSIMULATED = 0x00000010;
20   const TTMBED_EMBEDEUDC                 = 0x00000020;
21   const TTEMBED_VALIDATIONTESTS          = 0x00000040; // Deprecated
22   const TTEMBED_WEBOBJECT      = 0x00000080;
23   const TTEMBED_XORENCRYPTDATA = 0x10000000;
24
25   /**
26    * @var Header
27    */
28   public $header;
29
30   function parseHeader() {
31     if (!empty($this->header)) {
32       return;
33     }
34
35     $this->header = new Header($this);
36     $this->header->parse();
37   }
38
39   function parse() {
40     $this->parseHeader();
41
42     $flags = $this->header->data["Flags"];
43
44     if ($flags & self::TTEMBED_TTCOMPRESSED) {
45       $mtx_version    = $this->readUInt8();
46       $mtx_copy_limit = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8();
47       $mtx_offset_1   = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8();
48       $mtx_offset_2   = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8();
49       /*
50       var_dump("$mtx_version $mtx_copy_limit $mtx_offset_1 $mtx_offset_2");
51
52       $pos = $this->pos();
53       $size = $mtx_offset_1 - $pos;
54       var_dump("pos: $pos");
55       var_dump("size: $size");*/
56     }
57
58     if ($flags & self::TTEMBED_XORENCRYPTDATA) {
59       // Process XOR
60     }
61     // TODO Read font data ...
62   }
63
64     /**
65      * Little endian version of the read method
66      *
67      * @param int $n The number of bytes to read
68      *
69      * @return string
70      */
71   public function read($n) {
72     if ($n < 1) {
73       return "";
74     }
75
76     $string = fread($this->f, $n);
77     $chunks = str_split($string, 2);
78     $chunks = array_map("strrev", $chunks);
79
80     return implode("", $chunks);
81   }
82
83   public function readUInt32() {
84     $uint32 = parent::readUInt32();
85
86     return $uint32 >> 16 & 0x0000FFFF | $uint32 << 16 & 0xFFFF0000;
87   }
88
89   /**
90    * Get font copyright
91    *
92    * @return string|null
93    */
94   function getFontCopyright() {
95     return null;
96   }
97
98   /**
99    * Get font name
100    *
101    * @return string|null
102    */
103   function getFontName() {
104     return $this->header->data["FamilyName"];
105   }
106
107   /**
108    * Get font subfamily
109    *
110    * @return string|null
111    */
112   function getFontSubfamily() {
113     return $this->header->data["StyleName"];
114   }
115
116   /**
117    * Get font subfamily ID
118    *
119    * @return string|null
120    */
121   function getFontSubfamilyID() {
122     return $this->header->data["StyleName"];
123   }
124
125   /**
126    * Get font full name
127    *
128    * @return string|null
129    */
130   function getFontFullName() {
131     return $this->header->data["FullName"];
132   }
133
134   /**
135    * Get font version
136    *
137    * @return string|null
138    */
139   function getFontVersion() {
140     return $this->header->data["VersionName"];
141   }
142
143   /**
144    * Get font weight
145    *
146    * @return string|null
147    */
148   function getFontWeight() {
149     return $this->header->data["Weight"];
150   }
151
152   /**
153    * Get font Postscript name
154    *
155    * @return string|null
156    */
157   function getFontPostscriptName() {
158     return null;
159   }
160 }