fixes
This commit is contained in:
159
vendor/phenx/php-font-lib/src/FontLib/EOT/File.php
vendored
Normal file
159
vendor/phenx/php-font-lib/src/FontLib/EOT/File.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* @package php-font-lib
|
||||
* @link https://github.com/PhenX/php-font-lib
|
||||
* @author Fabien Ménager <fabien.menager@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
*/
|
||||
|
||||
namespace FontLib\EOT;
|
||||
|
||||
/**
|
||||
* EOT font file.
|
||||
*
|
||||
* @package php-font-lib
|
||||
*/
|
||||
class File extends \FontLib\TrueType\File {
|
||||
const TTEMBED_SUBSET = 0x00000001;
|
||||
const TTEMBED_TTCOMPRESSED = 0x00000004;
|
||||
const TTEMBED_FAILIFVARIATIONSIMULATED = 0x00000010;
|
||||
const TTMBED_EMBEDEUDC = 0x00000020;
|
||||
const TTEMBED_VALIDATIONTESTS = 0x00000040; // Deprecated
|
||||
const TTEMBED_WEBOBJECT = 0x00000080;
|
||||
const TTEMBED_XORENCRYPTDATA = 0x10000000;
|
||||
|
||||
/**
|
||||
* @var Header
|
||||
*/
|
||||
public $header;
|
||||
|
||||
function parseHeader() {
|
||||
if (!empty($this->header)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->header = new Header($this);
|
||||
$this->header->parse();
|
||||
}
|
||||
|
||||
function parse() {
|
||||
$this->parseHeader();
|
||||
|
||||
$flags = $this->header->data["Flags"];
|
||||
|
||||
if ($flags & self::TTEMBED_TTCOMPRESSED) {
|
||||
$mtx_version = $this->readUInt8();
|
||||
$mtx_copy_limit = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8();
|
||||
$mtx_offset_1 = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8();
|
||||
$mtx_offset_2 = $this->readUInt8() << 16 | $this->readUInt8() << 8 | $this->readUInt8();
|
||||
/*
|
||||
var_dump("$mtx_version $mtx_copy_limit $mtx_offset_1 $mtx_offset_2");
|
||||
|
||||
$pos = $this->pos();
|
||||
$size = $mtx_offset_1 - $pos;
|
||||
var_dump("pos: $pos");
|
||||
var_dump("size: $size");*/
|
||||
}
|
||||
|
||||
if ($flags & self::TTEMBED_XORENCRYPTDATA) {
|
||||
// Process XOR
|
||||
}
|
||||
// TODO Read font data ...
|
||||
}
|
||||
|
||||
/**
|
||||
* Little endian version of the read method
|
||||
*
|
||||
* @param int $n The number of bytes to read
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function read($n) {
|
||||
if ($n < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$string = (string) fread($this->f, $n);
|
||||
$chunks = mb_str_split($string, 2, '8bit');
|
||||
$chunks = array_map("strrev", $chunks);
|
||||
return implode("", $chunks);
|
||||
}
|
||||
|
||||
public function readUInt32() {
|
||||
$uint32 = parent::readUInt32();
|
||||
|
||||
return $uint32 >> 16 & 0x0000FFFF | $uint32 << 16 & 0xFFFF0000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font copyright
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontCopyright() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontName() {
|
||||
return $this->header->data["FamilyName"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font subfamily
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontSubfamily() {
|
||||
return $this->header->data["StyleName"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font subfamily ID
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontSubfamilyID() {
|
||||
return $this->header->data["StyleName"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font full name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontFullName() {
|
||||
return $this->header->data["FullName"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font version
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontVersion() {
|
||||
return $this->header->data["VersionName"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font weight
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontWeight() {
|
||||
return $this->header->data["Weight"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font Postscript name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getFontPostscriptName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
113
vendor/phenx/php-font-lib/src/FontLib/EOT/Header.php
vendored
Normal file
113
vendor/phenx/php-font-lib/src/FontLib/EOT/Header.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @package php-font-lib
|
||||
* @link https://github.com/PhenX/php-font-lib
|
||||
* @author Fabien Ménager <fabien.menager@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
*/
|
||||
|
||||
namespace FontLib\EOT;
|
||||
|
||||
use Exception;
|
||||
use FontLib\Font;
|
||||
|
||||
/**
|
||||
* TrueType font file header.
|
||||
*
|
||||
* @package php-font-lib
|
||||
*
|
||||
* @property File $font
|
||||
*/
|
||||
class Header extends \FontLib\Header {
|
||||
protected $def = array(
|
||||
"format" => self::uint32,
|
||||
"numTables" => self::uint16,
|
||||
"searchRange" => self::uint16,
|
||||
"entrySelector" => self::uint16,
|
||||
"rangeShift" => self::uint16,
|
||||
);
|
||||
|
||||
public function parse() {
|
||||
$font = $this->font;
|
||||
|
||||
$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,
|
||||
));
|
||||
|
||||
$this->data["Padding1"] = $font->readUInt16();
|
||||
$this->readString("FamilyName");
|
||||
|
||||
$this->data["Padding2"] = $font->readUInt16();
|
||||
$this->readString("StyleName");
|
||||
|
||||
$this->data["Padding3"] = $font->readUInt16();
|
||||
$this->readString("VersionName");
|
||||
|
||||
$this->data["Padding4"] = $font->readUInt16();
|
||||
$this->readString("FullName");
|
||||
|
||||
switch ($this->data["Version"]) {
|
||||
default:
|
||||
throw new Exception("Unknown EOT version " . $this->data["Version"]);
|
||||
|
||||
case 0x00010000:
|
||||
// Nothing to do more
|
||||
break;
|
||||
|
||||
case 0x00020001:
|
||||
$this->data["Padding5"] = $font->readUInt16();
|
||||
$this->readString("RootString");
|
||||
break;
|
||||
|
||||
case 0x00020002:
|
||||
$this->data["Padding5"] = $font->readUInt16();
|
||||
$this->readString("RootString");
|
||||
|
||||
$this->data["RootStringCheckSum"] = $font->readUInt32();
|
||||
$this->data["EUDCCodePage"] = $font->readUInt32();
|
||||
|
||||
$this->data["Padding6"] = $font->readUInt16();
|
||||
$this->readString("Signature");
|
||||
|
||||
$this->data["EUDCFlags"] = $font->readUInt32();
|
||||
$this->data["EUDCFontSize"] = $font->readUInt32();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($this->data["RootString"])) {
|
||||
$this->data["RootString"] = explode("\0", $this->data["RootString"]);
|
||||
}
|
||||
}
|
||||
|
||||
private function readString($name) {
|
||||
$font = $this->font;
|
||||
$size = $font->readUInt16();
|
||||
|
||||
$this->data["{$name}Size"] = $size;
|
||||
$this->data[$name] = Font::UTF16ToUTF8($font->read($size));
|
||||
}
|
||||
|
||||
public function encode() {
|
||||
//return $this->font->pack($this->def, $this->data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user