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
14 * @package php-font-lib
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;
30 function parseHeader() {
31 if (!empty($this->header)) {
35 $this->header = new Header($this);
36 $this->header->parse();
42 $flags = $this->header->data["Flags"];
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();
50 var_dump("$mtx_version $mtx_copy_limit $mtx_offset_1 $mtx_offset_2");
53 $size = $mtx_offset_1 - $pos;
54 var_dump("pos: $pos");
55 var_dump("size: $size");*/
58 if ($flags & self::TTEMBED_XORENCRYPTDATA) {
61 // TODO Read font data ...
65 * Little endian version of the read method
67 * @param int $n The number of bytes to read
71 public function read($n) {
76 $string = fread($this->f, $n);
77 $chunks = str_split($string, 2);
78 $chunks = array_map("strrev", $chunks);
80 return implode("", $chunks);
83 public function readUInt32() {
84 $uint32 = parent::readUInt32();
86 return $uint32 >> 16 & 0x0000FFFF | $uint32 << 16 & 0xFFFF0000;
94 function getFontCopyright() {
101 * @return string|null
103 function getFontName() {
104 return $this->header->data["FamilyName"];
110 * @return string|null
112 function getFontSubfamily() {
113 return $this->header->data["StyleName"];
117 * Get font subfamily ID
119 * @return string|null
121 function getFontSubfamilyID() {
122 return $this->header->data["StyleName"];
128 * @return string|null
130 function getFontFullName() {
131 return $this->header->data["FullName"];
137 * @return string|null
139 function getFontVersion() {
140 return $this->header->data["VersionName"];
146 * @return string|null
148 function getFontWeight() {
149 return $this->header->data["Weight"];
153 * Get font Postscript name
155 * @return string|null
157 function getFontPostscriptName() {