Pdf/FileParser/Font.php
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Pdf
- Subpackage
- FileParser
- Version
- $Id: Font.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Pdf_FileParser_Font
Defines the public interface for concrete subclasses which are responsible for parsing the raw binary data from the font file on disk. Also provides a debug logging interface and a couple of shared utility methods.
- Parent(s)
- \Zend_Pdf_FileParser
- Children
- \Zend_Pdf_FileParser_Font_OpenType
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
BYTE_ORDER_LITTLE_ENDIAN
= 0- Inherited_from
- \Zend_Pdf_FileParser::BYTE_ORDER_LITTLE_ENDIAN
BYTE_ORDER_BIG_ENDIAN
= 1- Inherited_from
- \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN
Properties

\Zend_Pdf_FileParserDataSource $_dataSource = nullnullDetails- Type
- \Zend_Pdf_FileParserDataSource
- Inherited_from
- \Zend_Pdf_FileParser::$$_dataSource

boolean $_debug = falsefalseDetails- Type
- boolean

boolean $_isParsed = falsefalseDetails- Type
- boolean
- Inherited_from
- \Zend_Pdf_FileParser::$$_isParsed

boolean $_isScreened = falsefalseDetails- Type
- boolean
- Inherited_from
- \Zend_Pdf_FileParser::$$_isScreened
Methods

__construct(\Zend_Pdf_FileParserDataSource $dataSource) : voidObject constructor.
Validates the data source and enables debug logging if so configured.
| Name | Type | Description |
|---|---|---|
| $dataSource | \Zend_Pdf_FileParserDataSource |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

__get(string $property) : mixedGet handler
| Name | Type | Description |
|---|---|---|
| $property | string |
| Type | Description |
|---|---|
| mixed |

__set(string $property, mixed $value) : voidSet handler
NOTE: This method is protected. Other classes may freely interrogate the font properties, but only this and its subclasses may set them.
| Name | Type | Description |
|---|---|---|
| $property | string | |
| $value | mixed |

_debugLog(string $message) : voidIf debug logging is enabled, writes the log message.
The log message is a sprintf() style string and any number of arguments may accompany it as additional parameters.
| Name | Type | Description |
|---|---|---|
| $message | string |

getDataSource() : \Zend_Pdf_FileParserDataSourceReturns the data source object representing the file being parsed.
Inherited from: \Zend_Pdf_FileParser::getDataSource()| Type | Description |
|---|---|
| \Zend_Pdf_FileParserDataSource |

isBitSet(integer $bit, integer $bitField) : booleanReturns true if the specified bit is set in the integer bitfield.
Inherited from: \Zend_Pdf_FileParser::isBitSet()| Name | Type | Description |
|---|---|---|
| $bit | integer | Bit number to test (i.e. - 0-31) |
| $bitField | integer |
| Type | Description |
|---|---|
| boolean |

isParsed() : booleanReturns true if the file has been successfully parsed.
Inherited from: \Zend_Pdf_FileParser::isParsed()| Type | Description |
|---|---|
| boolean |

isScreened() : booleanReturns true if the file has passed a cursory validation check.
Inherited from: \Zend_Pdf_FileParser::isScreened()| Type | Description |
|---|---|
| boolean |

moveToOffset(integer $offset) : voidConvenience wrapper for the data source object's moveToOffset() method.
Inherited from: \Zend_Pdf_FileParser::moveToOffset()| Name | Type | Description |
|---|---|---|
| $offset | integer | Destination byte offset. |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

parse() : voidReads and parses the complete binary file.
Inherited from: \Zend_Pdf_FileParser::parse()Must set $this->_isParsed to true if successful.
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readBytes(integer $byteCount) : stringConvenience wrapper for the data source object's readBytes() method.
Inherited from: \Zend_Pdf_FileParser::readBytes()| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes to read. |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readFixed(integer $mantissaBits, integer $fractionBits, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) : floatReads the signed fixed-point number from the binary file at the current byte offset.
Inherited from: \Zend_Pdf_FileParser::readFixed()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.
| Name | Type | Description |
|---|---|---|
| $mantissaBits | integer | Number of bits in the mantissa |
| $fractionBits | integer | Number of bits in the fraction |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| Type | Description |
|---|---|
| float |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readInt(integer $size, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) : integerReads the signed integer value from the binary file at the current byte offset.
Inherited from: \Zend_Pdf_FileParser::readInt()Advances the offset by the number of bytes read. Throws an exception if an error occurs.
| Name | Type | Description |
|---|---|---|
| $size | integer | Size of integer in bytes: 1-4 |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| Type | Description |
|---|---|
| integer |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readStringMacRoman(integer $byteCount, string $characterSet = '') : stringReads the Mac Roman-encoded string from the binary file at the current offset location.
Overridden to fix return character set at UTF-16BE.
| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes (characters) to return. |
| $characterSet | string | (optional) --Ignored-- |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readStringPascal(string $characterSet = '', integer $lengthBytes = 1) : stringReads the Pascal string from the binary file at the current offset location.
Overridden to fix return character set at UTF-16BE.
| Name | Type | Description |
|---|---|---|
| $characterSet | string | (optional) --Ignored-- |
| $lengthBytes | integer | (optional) Number of bytes that make up the length. Default is 1. |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readStringUTF16(integer $byteCount, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN, string $characterSet = '') : stringReads the Unicode UTF-16-encoded string from the binary file at the current offset location.
Overridden to fix return character set at UTF-16BE.
| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes (characters * 2) to return. |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| $characterSet | string | (optional) --Ignored-- |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |
- Todo
- Deal with to-dos in the parent method.

readUInt(integer $size, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) : integerReads the unsigned integer value from the binary file at the current byte offset.
Inherited from: \Zend_Pdf_FileParser::readUInt()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!
| Name | Type | Description |
|---|---|---|
| $size | integer | Size of integer in bytes: 1-4 |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| Type | Description |
|---|---|
| integer |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

screen() : voidPerforms a cursory check to verify that the binary file is in the expected format.
Inherited from: \Zend_Pdf_FileParser::screen()Intended to quickly weed out obviously bogus files.
Must set $this->_isScreened to true if successful.
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

skipBytes(integer $byteCount) : voidConvenience wrapper for the data source object's skipBytes() method.
Inherited from: \Zend_Pdf_FileParser::skipBytes()| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes to skip. |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |