Abstract base class for OpenType font file parsers.
TrueType was originally developed by Apple and was adopted as the default font format for the Microsoft Windows platform. OpenType is an extension of TrueType, developed jointly by Microsoft and Adobe, which adds support for PostScript font data.
This abstract parser class forms the foundation for concrete subclasses which extract either TrueType or PostScript font data from the file.
All OpenType files use big-endian byte ordering.
The full TrueType and OpenType specifications can be found at:
package | Zend_Pdf |
---|---|
subpackage | FileParser |
copyright | Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license | New BSD License |
inherited_from | \Zend_Pdf_FileParser_Font |
__construct(\Zend_Pdf_FileParserDataSource $dataSource)
Verifies that the data source has been properly initialized.
\Zend_Pdf_FileParserDataSource
\Zend_Pdf_Exception |
---|
__destruct()
Discards the data source object.
__get(string $property) : mixed
string
mixed
__set(string $property, mixed $value)
NOTE: This method is protected. Other classes may freely interrogate the font properties, but only this and its subclasses may set them.
string
mixed
getDataSource() : \Zend_Pdf_FileParserDataSource
\Zend_Pdf_FileParserDataSource
getOffset()
getSize()
isBitSet(integer $bit, integer $bitField) : boolean
integer
Bit number to test (i.e. - 0-31)
integer
boolean
isParsed() : boolean
boolean
isScreened() : boolean
boolean
moveToOffset(integer $offset)
integer
Destination byte offset.
\Zend_Pdf_Exception |
---|
parse()
NOTE: This method should be overridden in subclasses to add type- specific parsing and set $this->isParsed.
\Zend_Pdf_Exception |
---|
parse()
Must set $this->_isParsed to true if successful.
\Zend_Pdf_Exception |
---|
readBytes(integer $byteCount) : string
integer
Number of bytes to read.
\Zend_Pdf_Exception |
---|
string
readFixed(integer $mantissaBits, integer $fractionBits, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN
) : float
Common fixed-point sizes are 2.14 and 16.16.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
integer
Number of bits in the mantissa
integer
Number of bits in the fraction
integer
(optional) Big- or little-endian byte order. Use the BYTEORDER constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian.
\Zend_Pdf_Exception |
---|
float
readInt(integer $size, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN
) : integer
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
integer
Size of integer in bytes: 1-4
integer
(optional) Big- or little-endian byte order. Use the BYTEORDER constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian.
\Zend_Pdf_Exception |
---|
integer
readStringMacRoman(integer $byteCount, string $characterSet = ''
) : string
You must supply the desired resulting character set.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
integer
Number of bytes (characters) to return.
string
(optional) Desired resulting character set. You may use any character set supported by {@link iconv()}. If omitted, uses 'current locale'.
\Zend_Pdf_Exception |
---|
string
readStringPascal(string $characterSet= ''
, integer $lengthBytes= 1
) : string
The length of the Pascal string is determined by reading the length bytes which preceed the character data. You must supply the desired resulting character set.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
string
(optional) Desired resulting character set. You may use any character set supported by {@link iconv()}. If omitted, uses 'current locale'.
integer
(optional) Number of bytes that make up the length. Default is 1.
\Zend_Pdf_Exception |
---|
string
readStringUTF16(integer $byteCount, integer $byteOrder= \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN
, string $characterSet= ''
) : string
The byte order of the UTF-16 string must be specified. You must also supply the desired resulting character set.
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
todo | Consider changing $byteCount to a character count. They are not always equivalent (in the case of surrogates). |
---|---|
todo | Make $byteOrder optional if there is a byte-order mark (BOM) in the string being extracted. |
integer
Number of bytes (characters * 2) to return.
integer
(optional) Big- or little-endian byte order. Use the BYTEORDER constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian.
string
(optional) Desired resulting character set. You may use any character set supported by {@link iconv()}. If omitted, uses 'current locale'.
\Zend_Pdf_Exception |
---|
string
readUInt(integer $size, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN
) : integer
Advances the offset by the number of bytes read. Throws an exception if an error occurs.
NOTE: If you ask for a 4-byte unsigned integer on a 32-bit machine, the resulting value WILL BE SIGNED because PHP uses signed integers internally for everything. To guarantee portability, be sure to use bitwise operators operators on large unsigned integers!
integer
Size of integer in bytes: 1-4
integer
(optional) Big- or little-endian byte order. Use the BYTEORDER constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian.
\Zend_Pdf_Exception |
---|
integer
screen()
NOTE: This method should be overridden in subclasses to check the specific format and set $this->_isScreened!
\Zend_Pdf_Exception |
---|
screen()
Must set $this->_isScreened to true if successful.
\Zend_Pdf_Exception |
---|
skipBytes(integer $byteCount)
integer
Number of bytes to skip.
\Zend_Pdf_Exception |
---|
writeDebug()
_debugLog(string $message)
The log message is a sprintf() style string and any number of arguments may accompany it as additional parameters.
string
_jumpToTable(string $tableName)
string
\Zend_Pdf_Exception |
---|
_languageCodeForPlatform(integer $platformID, $languageID) : string
integer
string
| null_parseCmapTable()
The cmap table provides the maps from character codes to font glyphs. There are usually at least two character maps in a font: Microsoft Unicode and Macintosh Roman. For very complex fonts, there may also be mappings for the characters in the Unicode Surrogates Area, which are UCS-4 characters.
todo | Need to rework the selection logic for picking a subtable. We should have an explicit list of preferences, followed by a list of those that are tolerable. Most specifically, since everything above this layer deals in Unicode, we need to be sure to only accept format 0 MacRoman tables. |
---|
\Zend_Pdf_Exception |
---|
_parseHeadTable()
The head table contains global information about the font such as the revision number and global metrics.
\Zend_Pdf_Exception |
---|
_parseHheaTable()
The hhea table contains information used for horizontal layout. It also contains some vertical layout information for Apple systems. The vertical layout information for the PDF file is usually taken from the OS/2 table.
\Zend_Pdf_Exception |
---|
_parseHmtxTable()
The hmtx table contains the horizontal metrics for every glyph contained within the font. These are the critical values for horizontal layout of text.
\Zend_Pdf_Exception |
---|
_parseMaxpTable()
The hhea table contains information used for horizontal layout. It also contains some vertical layout information for Apple systems. The vertical layout information for the PDF file is usually taken from the OS/2 table.
\Zend_Pdf_Exception |
---|
_parseNameTable()
The name table contains all of the identifying strings associated with the font such as its name, copyright, trademark, license, etc.
\Zend_Pdf_Exception |
---|
_parseOs2Table()
The OS/2 table contains additional metrics data that is required to use the font on the OS/2 or Microsoft Windows platforms. It is not required for Macintosh fonts, so may not always be present. When available, we use this table to determine most of the vertical layout and stylistic information and for the font.
\Zend_Pdf_Exception |
---|
_parsePostTable()
The post table contains additional information required for using the font on PostScript printers. It also contains the preferred location and thickness for an underline, which is used by our layout code.
\Zend_Pdf_Exception |
---|
_parseTableDirectory()
The table directory contains the identifier, checksum, byte offset, and length of each of the information tables housed in the font file.
\Zend_Pdf_Exception |
---|
_readScalerType() : integer
The scaler type defines the type of font: OpenType font files may contain TrueType or PostScript outlines. Throws an exception if the scaler type is not recognized.
\Zend_Pdf_Exception |
---|
integer
_readTableVersion(float $minVersion, $maxVersion) : float
If the version is incompatible, throws an exception. If it is compatible, returns the version number.
float
Minimum compatible version number.
\Zend_Pdf_Exception |
---|
float
Table version number.$_dataSource : \Zend_Pdf_FileParserDataSource
null
$_isParsed : boolean
false
$_isScreened : boolean
false
$_scalerType : integer
0
$_tableDirectory : array
array()
$_debug : boolean
false
$_fontProperties : array
array()
BYTE_ORDER_BIG_ENDIAN = 1
BYTE_ORDER_LITTLE_ENDIAN = 0