vendor: Uprade php-font-lib to version 0.4

refs #10044
This commit is contained in:
Eric Lippmann 2015-09-01 12:55:34 +02:00
parent 5da88d0767
commit 6556059afd
21 changed files with 64 additions and 62 deletions

View File

@ -3,7 +3,7 @@ tar xzf dompdf-0.6.1.tar.gz --strip-components 1 dompdf-0.6.1/{include/*.php,lib
rm dompdf-0.6.1.tar.gz rm dompdf-0.6.1.tar.gz
mv LICENSE.LGPL LICENSE mv LICENSE.LGPL LICENSE
curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.3.1 -o php-font-lib-0.3.1.tar.gz curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.4 -o php-font-lib-0.4.tar.gz
mkdir lib/php-font-lib/classes mkdir -p lib/php-font-lib/classes
tar xzf php-font-lib-0.3.1.tar.gz --strip-components 3 -C lib/php-font-lib/classes php-font-lib-0.3.1/src/FontLib tar xzf php-font-lib-0.4.tar.gz --strip-components 3 -C lib/php-font-lib/classes php-font-lib-0.4/src/FontLib
rm php-font-lib-0.3.1.tar.gz rm php-font-lib-0.4.tar.gz

View File

@ -16,7 +16,7 @@ use FontLib\TrueType\File;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Adobe_Font_Metrics { class AdobeFontMetrics {
private $f; private $f;
/** /**
@ -38,7 +38,7 @@ class Adobe_Font_Metrics {
throw new \Exception("Unkown encoding ($encoding)"); throw new \Exception("Unkown encoding ($encoding)");
} }
$map = new Encoding_Map($map_file); $map = new EncodingMap($map_file);
$map_data = $map->parse(); $map_data = $map->parse();
} }

View File

@ -13,7 +13,7 @@ namespace FontLib;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Binary_Stream { class BinaryStream {
/** /**
* @var resource The file pointer * @var resource The file pointer
*/ */

View File

@ -61,9 +61,13 @@ class File extends \FontLib\TrueType\File {
// TODO Read font data ... // TODO Read font data ...
} }
/** /**
* Little endian version of the read method * Little endian version of the read method
*/ *
* @param int $n The number of bytes to read
*
* @return string
*/
public function read($n) { public function read($n) {
if ($n < 1) { if ($n < 1) {
return ""; return "";

View File

@ -13,7 +13,7 @@ namespace FontLib;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Encoding_Map { class EncodingMap {
private $f; private $f;
function __construct($file) { function __construct($file) {
@ -24,7 +24,7 @@ class Encoding_Map {
$map = array(); $map = array();
while ($line = fgets($this->f)) { while ($line = fgets($this->f)) {
if (preg_match("/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/", $line, $matches)) { if (preg_match('/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/', $line, $matches)) {
$unicode = (hexdec($matches[2]) << 8) + hexdec($matches[3]); $unicode = (hexdec($matches[2]) << 8) + hexdec($matches[3]);
$map[hexdec($matches[1])] = array($unicode, $matches[4]); $map[hexdec($matches[1])] = array($unicode, $matches[4]);
} }

View File

@ -10,14 +10,14 @@ namespace FontLib\Glyph;
use FontLib\Table\Type\glyf; use FontLib\Table\Type\glyf;
use FontLib\TrueType\File; use FontLib\TrueType\File;
use FontLib\Binary_Stream; use FontLib\BinaryStream;
/** /**
* `glyf` font table. * `glyf` font table.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Outline extends Binary_Stream { class Outline extends BinaryStream {
/** /**
* @var \FontLib\Table\Type\glyf * @var \FontLib\Table\Type\glyf
*/ */
@ -47,12 +47,12 @@ class Outline extends Binary_Stream {
$font->seek($offset); $font->seek($offset);
if ($font->readInt16() > -1) { if ($font->readInt16() > -1) {
/** @var Outline_Simple $glyph */ /** @var OutlineSimple $glyph */
$glyph = new Outline_Simple($table, $offset, $size); $glyph = new OutlineSimple($table, $offset, $size);
} }
else { else {
/** @var Outline_Composite $glyph */ /** @var OutlineComposite $glyph */
$glyph = new Outline_Composite($table, $offset, $size); $glyph = new OutlineComposite($table, $offset, $size);
} }
$glyph->parse(); $glyph->parse();

View File

@ -13,7 +13,7 @@ namespace FontLib\Glyph;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Outline_Component { class OutlineComponent {
public $flags; public $flags;
public $glyphIndex; public $glyphIndex;
public $a, $b, $c, $d, $e, $f; public $a, $b, $c, $d, $e, $f;

View File

@ -9,14 +9,12 @@
namespace FontLib\Glyph; namespace FontLib\Glyph;
use FontLib\Table\Type\glyf;
/** /**
* Composite glyph outline * Composite glyph outline
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Outline_Composite extends Outline { class OutlineComposite extends Outline {
const ARG_1_AND_2_ARE_WORDS = 0x0001; const ARG_1_AND_2_ARE_WORDS = 0x0001;
const ARGS_ARE_XY_VALUES = 0x0002; const ARGS_ARE_XY_VALUES = 0x0002;
const ROUND_XY_TO_GRID = 0x0004; const ROUND_XY_TO_GRID = 0x0004;
@ -29,7 +27,7 @@ class Outline_Composite extends Outline {
const OVERLAP_COMPOUND = 0x0400; const OVERLAP_COMPOUND = 0x0400;
/** /**
* @var Outline_Component[] * @var OutlineComponent[]
*/ */
public $components = array(); public $components = array();
@ -113,7 +111,7 @@ class Outline_Composite extends Outline {
// //
//} //}
$component = new Outline_Component(); $component = new OutlineComponent();
$component->flags = $flags; $component->flags = $flags;
$component->glyphIndex = $glyphIndex; $component->glyphIndex = $glyphIndex;
$component->a = $a; $component->a = $a;
@ -219,7 +217,7 @@ class Outline_Composite extends Outline {
public function getSVGContours() { public function getSVGContours() {
$contours = array(); $contours = array();
/** @var \FontLib\Table\\FontLib\Table\Type\glyf $glyph_data */ /** @var \FontLib\Table\Type\glyf $glyph_data */
$glyph_data = $this->getFont()->getTableObject("glyf"); $glyph_data = $this->getFont()->getTableObject("glyf");
/** @var Outline[] $glyphs */ /** @var Outline[] $glyphs */

View File

@ -14,7 +14,7 @@ namespace FontLib\Glyph;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Outline_Simple extends Outline { class OutlineSimple extends Outline {
const ON_CURVE = 0x01; const ON_CURVE = 0x01;
const X_SHORT_VECTOR = 0x02; const X_SHORT_VECTOR = 0x02;
const Y_SHORT_VECTOR = 0x04; const Y_SHORT_VECTOR = 0x04;

View File

@ -14,7 +14,7 @@ use FontLib\TrueType\File;
* *
* @package php-font-lib * @package php-font-lib
*/ */
abstract class Header extends Binary_Stream { abstract class Header extends BinaryStream {
/** /**
* @var File * @var File
*/ */

View File

@ -13,6 +13,6 @@ namespace FontLib\OpenType;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Table_Directory_Entry extends \FontLib\TrueType\Table_Directory_Entry { class TableDirectoryEntry extends \FontLib\TrueType\TableDirectoryEntry {
} }

View File

@ -9,14 +9,14 @@ namespace FontLib\Table;
use FontLib\TrueType\File; use FontLib\TrueType\File;
use FontLib\Font; use FontLib\Font;
use FontLib\Binary_Stream; use FontLib\BinaryStream;
/** /**
* Generic Font table directory entry. * Generic Font table directory entry.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Directory_Entry extends Binary_Stream { class DirectoryEntry extends BinaryStream {
/** /**
* @var File * @var File
*/ */

View File

@ -9,23 +9,23 @@ namespace FontLib\Table;
use FontLib\TrueType\File; use FontLib\TrueType\File;
use FontLib\Font; use FontLib\Font;
use FontLib\Binary_Stream; use FontLib\BinaryStream;
/** /**
* Generic font table. * Generic font table.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Table extends Binary_Stream { class Table extends BinaryStream {
/** /**
* @var Directory_Entry * @var DirectoryEntry
*/ */
protected $entry; protected $entry;
protected $def = array(); protected $def = array();
public $data; public $data;
final public function __construct(Directory_Entry $entry) { final public function __construct(DirectoryEntry $entry) {
$this->entry = $entry; $this->entry = $entry;
$entry->setTable($this); $entry->setTable($this);
} }

View File

@ -10,7 +10,7 @@ namespace FontLib\Table\Type;
use FontLib\Table\Table; use FontLib\Table\Table;
use FontLib\Glyph\Outline; use FontLib\Glyph\Outline;
use FontLib\Glyph\Outline_Simple; use FontLib\Glyph\OutlineSimple;
/** /**
* `glyf` font table. * `glyf` font table.
@ -106,7 +106,7 @@ class glyf extends Table {
); );
$shape_json = json_encode($shape); $shape_json = json_encode($shape);
$type = ($glyph instanceof Outline_Simple ? "simple" : "composite"); $type = ($glyph instanceof OutlineSimple ? "simple" : "composite");
$char = isset($glyphIndexArray[$g]) ? $glyphIndexArray[$g] : 0; $char = isset($glyphIndexArray[$g]) ? $glyphIndexArray[$g] : 0;
$name = isset($names[$g]) ? $names[$g] : sprintf("uni%04x", $char); $name = isset($names[$g]) ? $names[$g] : sprintf("uni%04x", $char);
$char = $char ? "&#{$glyphIndexArray[$g]};" : ""; $char = $char ? "&#{$glyphIndexArray[$g]};" : "";

View File

@ -143,8 +143,8 @@ class name extends Table {
$records = array(); $records = array();
for ($i = 0; $i < $data["count"]; $i++) { for ($i = 0; $i < $data["count"]; $i++) {
$record = new name_Record(); $record = new nameRecord();
$record_data = $font->unpack(name_Record::$format); $record_data = $font->unpack(nameRecord::$format);
$record->map($record_data); $record->map($record_data);
$records[] = $record; $records[] = $record;
@ -166,7 +166,7 @@ class name extends Table {
protected function _encode() { protected function _encode() {
$font = $this->getFont(); $font = $this->getFont();
/** @var name_Record[] $records */ /** @var nameRecord[] $records */
$records = $this->data["records"]; $records = $this->data["records"];
$count_records = count($records); $count_records = count($records);
@ -180,7 +180,7 @@ class name extends Table {
$record->length = mb_strlen($record->getUTF16(), "8bit"); $record->length = mb_strlen($record->getUTF16(), "8bit");
$record->offset = $offset; $record->offset = $offset;
$offset += $record->length; $offset += $record->length;
$length += $font->pack(name_Record::$format, (array)$record); $length += $font->pack(nameRecord::$format, (array)$record);
} }
foreach ($records as $record) { foreach ($records as $record) {

View File

@ -8,14 +8,14 @@
namespace FontLib\Table\Type; namespace FontLib\Table\Type;
use FontLib\Font; use FontLib\Font;
use FontLib\Binary_Stream; use FontLib\BinaryStream;
/** /**
* Font table name record. * Font table name record.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class name_Record extends Binary_Stream { class nameRecord extends BinaryStream {
public $platformID; public $platformID;
public $platformSpecificID; public $platformSpecificID;
public $languageID; public $languageID;

View File

@ -9,7 +9,7 @@
namespace FontLib\TrueType; namespace FontLib\TrueType;
use Countable; use Countable;
use FontLib\Binary_Stream; use FontLib\BinaryStream;
use Iterator; use Iterator;
use OutOfBoundsException; use OutOfBoundsException;
@ -18,7 +18,7 @@ use OutOfBoundsException;
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Collection extends Binary_Stream implements Iterator, Countable { class Collection extends BinaryStream implements Iterator, Countable {
/** /**
* Current iterator position. * Current iterator position.
* *

View File

@ -8,21 +8,21 @@
namespace FontLib\TrueType; namespace FontLib\TrueType;
use FontLib\Adobe_Font_Metrics; use FontLib\AdobeFontMetrics;
use FontLib\Font; use FontLib\Font;
use FontLib\Binary_Stream; use FontLib\BinaryStream;
use FontLib\Table\Table; use FontLib\Table\Table;
use FontLib\Table\Directory_Entry; use FontLib\Table\DirectoryEntry;
use FontLib\Table\Type\glyf; use FontLib\Table\Type\glyf;
use FontLib\Table\Type\name; use FontLib\Table\Type\name;
use FontLib\Table\Type\name_Record; use FontLib\Table\Type\nameRecord;
/** /**
* TrueType font file. * TrueType font file.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class File extends Binary_Stream { class File extends BinaryStream {
/** /**
* @var Header * @var Header
*/ */
@ -228,7 +228,7 @@ class File extends Binary_Stream {
Font::d("Tables : " . implode(", ", $tags)); Font::d("Tables : " . implode(", ", $tags));
/** @var Directory_Entry[] $entries */ /** @var DirectoryEntry[] $entries */
$entries = array(); $entries = array();
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (!isset($this->directory[$tag])) { if (!isset($this->directory[$tag])) {
@ -282,10 +282,10 @@ class File extends Binary_Stream {
$type = $this->getFontType(); $type = $this->getFontType();
$class = "FontLib\\$type\\Table_Directory_Entry"; $class = "FontLib\\$type\\TableDirectoryEntry";
for ($i = 0; $i < $this->header->data["numTables"]; $i++) { for ($i = 0; $i < $this->header->data["numTables"]; $i++) {
/** @var Table_Directory_Entry $entry */ /** @var TableDirectoryEntry $entry */
$entry = new $class($this); $entry = new $class($this);
$entry->parse(); $entry->parse();
@ -352,12 +352,12 @@ class File extends Binary_Stream {
} }
} }
function addDirectoryEntry(Directory_Entry $entry) { function addDirectoryEntry(DirectoryEntry $entry) {
$this->directory[$entry->tag] = $entry; $this->directory[$entry->tag] = $entry;
} }
function saveAdobeFontMetrics($file, $encoding = null) { function saveAdobeFontMetrics($file, $encoding = null) {
$afm = new Adobe_Font_Metrics($this); $afm = new AdobeFontMetrics($this);
$afm->write($file, $encoding); $afm->write($file, $encoding);
} }
@ -369,7 +369,7 @@ class File extends Binary_Stream {
* @return string|null * @return string|null
*/ */
function getNameTableString($nameID) { function getNameTableString($nameID) {
/** @var name_Record[] $records */ /** @var nameRecord[] $records */
$records = $this->getData("name", "records"); $records = $this->getData("name", "records");
if (!isset($records[$nameID])) { if (!isset($records[$nameID])) {

View File

@ -8,14 +8,14 @@
namespace FontLib\TrueType; namespace FontLib\TrueType;
use FontLib\Table\Directory_Entry; use FontLib\Table\DirectoryEntry;
/** /**
* TrueType table directory entry. * TrueType table directory entry.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Table_Directory_Entry extends Directory_Entry { class TableDirectoryEntry extends DirectoryEntry {
function __construct(File $font) { function __construct(File $font) {
parent::__construct($font); parent::__construct($font);
} }

View File

@ -8,14 +8,14 @@
namespace FontLib\WOFF; namespace FontLib\WOFF;
use FontLib\Table\Directory_Entry; use FontLib\Table\DirectoryEntry;
/** /**
* WOFF font file. * WOFF font file.
* *
* @package php-font-lib * @package php-font-lib
* *
* @property Table_Directory_Entry[] $directory * @property TableDirectoryEntry[] $directory
*/ */
class File extends \FontLib\TrueType\File { class File extends \FontLib\TrueType\File {
function parseHeader() { function parseHeader() {
@ -63,7 +63,7 @@ class File extends \FontLib\TrueType\File {
$offset += $this->writeUInt32($dataOffset); // offset $offset += $this->writeUInt32($dataOffset); // offset
$offset += $this->writeUInt32($length); // length $offset += $this->writeUInt32($length); // length
$offset += $this->writeUInt32($length); // origLength $offset += $this->writeUInt32($length); // origLength
$offset += $this->writeUInt32(Directory_Entry::computeChecksum($data)); // checksum $offset += $this->writeUInt32(DirectoryEntry::computeChecksum($data)); // checksum
// Data // Data
$this->seek($dataOffset); $this->seek($dataOffset);

View File

@ -8,14 +8,14 @@
namespace FontLib\WOFF; namespace FontLib\WOFF;
use FontLib\Table\Directory_Entry; use FontLib\Table\DirectoryEntry;
/** /**
* WOFF font file table directory entry. * WOFF font file table directory entry.
* *
* @package php-font-lib * @package php-font-lib
*/ */
class Table_Directory_Entry extends Directory_Entry { class TableDirectoryEntry extends DirectoryEntry {
public $origLength; public $origLength;
function __construct(File $font) { function __construct(File $font) {