| 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 |
use Exception; |
| 11 |
use WCPOS\Vendor\FontLib\Font; |
| 12 |
/** |
| 13 |
* TrueType font file header. |
| 14 |
* |
| 15 |
* @package php-font-lib |
| 16 |
* |
| 17 |
* @property File $font |
| 18 |
*/ |
| 19 |
class Header extends \WCPOS\Vendor\FontLib\Header |
| 20 |
{ |
| 21 |
protected $def = array("format" => self::uint32, "numTables" => self::uint16, "searchRange" => self::uint16, "entrySelector" => self::uint16, "rangeShift" => self::uint16); |
| 22 |
public function parse() |
| 23 |
{ |
| 24 |
$font = $this->font; |
| 25 |
$this->data = $font->unpack(array("EOTSize" => self::uint32, "FontDataSize" => self::uint32, "Version" => self::uint32, "Flags" => self::uint32, "FontPANOSE" => array(self::uint8, 10), "Charset" => self::uint8, "Italic" => self::uint8, "Weight" => self::uint32, "fsType" => self::uint16, "MagicNumber" => self::uint16, "UnicodeRange1" => self::uint32, "UnicodeRange2" => self::uint32, "UnicodeRange3" => self::uint32, "UnicodeRange4" => self::uint32, "CodePageRange1" => self::uint32, "CodePageRange2" => self::uint32, "CheckSumAdjustment" => self::uint32, "Reserved1" => self::uint32, "Reserved2" => self::uint32, "Reserved3" => self::uint32, "Reserved4" => self::uint32)); |
| 26 |
$this->data["Padding1"] = $font->readUInt16(); |
| 27 |
$this->readString("FamilyName"); |
| 28 |
$this->data["Padding2"] = $font->readUInt16(); |
| 29 |
$this->readString("StyleName"); |
| 30 |
$this->data["Padding3"] = $font->readUInt16(); |
| 31 |
$this->readString("VersionName"); |
| 32 |
$this->data["Padding4"] = $font->readUInt16(); |
| 33 |
$this->readString("FullName"); |
| 34 |
switch ($this->data["Version"]) { |
| 35 |
default: |
| 36 |
throw new Exception("Unknown EOT version " . $this->data["Version"]); |
| 37 |
case 0x10000: |
| 38 |
// Nothing to do more |
| 39 |
break; |
| 40 |
case 0x20001: |
| 41 |
$this->data["Padding5"] = $font->readUInt16(); |
| 42 |
$this->readString("RootString"); |
| 43 |
break; |
| 44 |
case 0x20002: |
| 45 |
$this->data["Padding5"] = $font->readUInt16(); |
| 46 |
$this->readString("RootString"); |
| 47 |
$this->data["RootStringCheckSum"] = $font->readUInt32(); |
| 48 |
$this->data["EUDCCodePage"] = $font->readUInt32(); |
| 49 |
$this->data["Padding6"] = $font->readUInt16(); |
| 50 |
$this->readString("Signature"); |
| 51 |
$this->data["EUDCFlags"] = $font->readUInt32(); |
| 52 |
$this->data["EUDCFontSize"] = $font->readUInt32(); |
| 53 |
break; |
| 54 |
} |
| 55 |
if (!empty($this->data["RootString"])) { |
| 56 |
$this->data["RootString"] = \explode("\x00", $this->data["RootString"]); |
| 57 |
} |
| 58 |
} |
| 59 |
private function readString($name) |
| 60 |
{ |
| 61 |
$font = $this->font; |
| 62 |
$size = $font->readUInt16(); |
| 63 |
$this->data["{$name}Size"] = $size; |
| 64 |
$this->data[$name] = Font::UTF16ToUTF8($font->read($size)); |
| 65 |
} |
| 66 |
public function encode() |
| 67 |
{ |
| 68 |
//return $this->font->pack($this->def, $this->data); |
| 69 |
} |
| 70 |
} |
| 71 |
|