| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package php-font-lib |
| 5 |
* @link https://github.com/dompdf/php-font-lib |
| 6 |
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
| 7 |
*/ |
| 8 |
namespace WCPOS\Vendor\FontLib\EOT; |
| 9 |
|
| 10 |
/** |
| 11 |
* EOT font file. |
| 12 |
* |
| 13 |
* @package php-font-lib |
| 14 |
*/ |
| 15 |
class File extends \WCPOS\Vendor\FontLib\TrueType\File |
| 16 |
{ |
| 17 |
const TTEMBED_SUBSET = 0x1; |
| 18 |
const TTEMBED_TTCOMPRESSED = 0x4; |
| 19 |
const TTEMBED_FAILIFVARIATIONSIMULATED = 0x10; |
| 20 |
const TTMBED_EMBEDEUDC = 0x20; |
| 21 |
const TTEMBED_VALIDATIONTESTS = 0x40; |
| 22 |
// Deprecated |
| 23 |
const TTEMBED_WEBOBJECT = 0x80; |
| 24 |
const TTEMBED_XORENCRYPTDATA = 0x10000000; |
| 25 |
/** |
| 26 |
* @var Header |
| 27 |
*/ |
| 28 |
public $header; |
| 29 |
function parseHeader() |
| 30 |
{ |
| 31 |
if (!empty($this->header)) { |
| 32 |
return; |
| 33 |
} |
| 34 |
$this->header = new Header($this); |
| 35 |
$this->header->parse(); |
| 36 |
} |
| 37 |
function parse() |
| 38 |
{ |
| 39 |
$this->parseHeader(); |
| 40 |
$flags = $this->header->data["Flags"]; |
| 41 |
if ($flags & self::TTEMBED_TTCOMPRESSED) { |
| 42 |
$mtx_version = $this->readUInt8(); |
| 43 |
$mtx_copy_limit = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8(); |
| 44 |
$mtx_offset_1 = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8(); |
| 45 |
$mtx_offset_2 = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8(); |
| 46 |
/* |
| 47 |
var_dump("$mtx_version $mtx_copy_limit $mtx_offset_1 $mtx_offset_2"); |
| 48 |
|
| 49 |
$pos = $this->pos(); |
| 50 |
$size = $mtx_offset_1 - $pos; |
| 51 |
var_dump("pos: $pos"); |
| 52 |
var_dump("size: $size");*/ |
| 53 |
} |
| 54 |
if ($flags & self::TTEMBED_XORENCRYPTDATA) { |
| 55 |
// Process XOR |
| 56 |
} |
| 57 |
// TODO Read font data ... |
| 58 |
} |
| 59 |
/** |
| 60 |
* Little endian version of the read method |
| 61 |
* |
| 62 |
* @param int $n The number of bytes to read |
| 63 |
* |
| 64 |
* @return string |
| 65 |
*/ |
| 66 |
public function read($n) |
| 67 |
{ |
| 68 |
if ($n < 1) { |
| 69 |
return ""; |
| 70 |
} |
| 71 |
$string = (string) \fread($this->f, $n); |
| 72 |
$chunks = \mb_str_split($string, 2, '8bit'); |
| 73 |
$chunks = \array_map("strrev", $chunks); |
| 74 |
return \implode("", $chunks); |
| 75 |
} |
| 76 |
public function readUInt32() |
| 77 |
{ |
| 78 |
$uint32 = parent::readUInt32(); |
| 79 |
return $uint32 >> 16 & 0xffff | $uint32 << 16 & 0xffff0000; |
| 80 |
} |
| 81 |
/** |
| 82 |
* Get font copyright |
| 83 |
* |
| 84 |
* @return string|null |
| 85 |
*/ |
| 86 |
function getFontCopyright() |
| 87 |
{ |
| 88 |
return null; |
| 89 |
} |
| 90 |
/** |
| 91 |
* Get font name |
| 92 |
* |
| 93 |
* @return string|null |
| 94 |
*/ |
| 95 |
function getFontName() |
| 96 |
{ |
| 97 |
return $this->header->data["FamilyName"]; |
| 98 |
} |
| 99 |
/** |
| 100 |
* Get font subfamily |
| 101 |
* |
| 102 |
* @return string|null |
| 103 |
*/ |
| 104 |
function getFontSubfamily() |
| 105 |
{ |
| 106 |
return $this->header->data["StyleName"]; |
| 107 |
} |
| 108 |
/** |
| 109 |
* Get font subfamily ID |
| 110 |
* |
| 111 |
* @return string|null |
| 112 |
*/ |
| 113 |
function getFontSubfamilyID() |
| 114 |
{ |
| 115 |
return $this->header->data["StyleName"]; |
| 116 |
} |
| 117 |
/** |
| 118 |
* Get font full name |
| 119 |
* |
| 120 |
* @return string|null |
| 121 |
*/ |
| 122 |
function getFontFullName() |
| 123 |
{ |
| 124 |
return $this->header->data["FullName"]; |
| 125 |
} |
| 126 |
/** |
| 127 |
* Get font version |
| 128 |
* |
| 129 |
* @return string|null |
| 130 |
*/ |
| 131 |
function getFontVersion() |
| 132 |
{ |
| 133 |
return $this->header->data["VersionName"]; |
| 134 |
} |
| 135 |
/** |
| 136 |
* Get font weight |
| 137 |
* |
| 138 |
* @return string|null |
| 139 |
*/ |
| 140 |
function getFontWeight() |
| 141 |
{ |
| 142 |
return $this->header->data["Weight"]; |
| 143 |
} |
| 144 |
/** |
| 145 |
* Get font Postscript name |
| 146 |
* |
| 147 |
* @return string|null |
| 148 |
*/ |
| 149 |
function getFontPostscriptName() |
| 150 |
{ |
| 151 |
return null; |
| 152 |
} |
| 153 |
} |
| 154 |
|