Abstract helper class for {@link Zend_Pdf_Resource_Font} which manages font character maps.

Defines the public interface for concrete subclasses which are responsible for mapping Unicode characters to the font's glyph numbers. Also provides shared utility methods.

Cmap objects should ordinarily be obtained through the factory method \cmapWithTypeData().

The supported character map types are those found in the OpenType spec. For additional detail on the internal binary format of these tables, see:

  • [http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html](http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html)
  • [http://www.microsoft.com/OpenType/OTSpec/cmap.htm](http://www.microsoft.com/OpenType/OTSpec/cmap.htm)
  • [http://partners.adobe.com/public/developer/opentype/index_cmap.html](http://partners.adobe.com/public/developer/opentype/index_cmap.html)
todo Write code for Zend_Pdf_FontCmap_HighByteMapping class.
todo Write code for Zend_Pdf_FontCmap_MixedCoverage class.
todo Write code for Zend_Pdf_FontCmap_TrimmedArray class.
todo Write code for Zend_Pdf_FontCmap_SegmentedCoverage class.
package Zend_Pdf
subpackage Fonts
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Object constructor

__construct(string $cmapData) 

Parses the raw binary table data. Throws an exception if the table is malformed.

Parameters

$cmapData

string

Raw binary cmap table data.

Exceptions

\Zend_Pdf_Exception

Instantiates the appropriate concrete subclass based on the type of cmap table and returns the instance.

cmapWithTypeData(integer $cmapType, mixed $cmapData) : \Zend_Pdf_Cmap
Static

The cmap type must be one of the following values:

  • [Zend_Pdf_Cmap::TYPE_BYTE_ENCODING](/classes/Zend_Pdf_Cmap.html#constant_TYPE_BYTE_ENCODING)
  • [Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC](/classes/Zend_Pdf_Cmap.html#constant_TYPE_BYTE_ENCODING_STATIC)
  • [Zend_Pdf_Cmap::TYPE_HIGH_BYTE_MAPPING](/classes/Zend_Pdf_Cmap.html#constant_TYPE_HIGH_BYTE_MAPPING)
  • [Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA](/classes/Zend_Pdf_Cmap.html#constant_TYPE_SEGMENT_TO_DELTA)
  • [Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE](/classes/Zend_Pdf_Cmap.html#constant_TYPE_TRIMMED_TABLE)
  • [Zend_Pdf_Cmap::TYPE_MIXED_COVERAGE](/classes/Zend_Pdf_Cmap.html#constant_TYPE_MIXED_COVERAGE)
  • [Zend_Pdf_Cmap::TYPE_TRIMMED_ARRAY](/classes/Zend_Pdf_Cmap.html#constant_TYPE_TRIMMED_ARRAY)
  • [Zend_Pdf_Cmap::TYPE_SEGMENTED_COVERAGE](/classes/Zend_Pdf_Cmap.html#constant_TYPE_SEGMENTED_COVERAGE)

Throws an exception if the table type is invalid or the cmap table data cannot be validated.

Parameters

$cmapType

integer

Type of cmap.

$cmapData

mixed

Cmap table data. Usually a string or array.

Exceptions

\Zend_Pdf_Exception

Returns

\Zend_Pdf_Cmap

Returns an array containing the Unicode characters that have entries in this character map.

getCoveredCharacters() : array

Returns

arrayUnicode character codes.

Returns the glyph number corresponding to the Unicode character.

glyphNumberForCharacter(integer $characterCode) : integer

If a particular character doesn't exist in this font, the special 'missing character glyph' will be substituted.

See also \glyphNumbersForCharacters() which is optimized for bulk operations.

Parameters

$characterCode

integer

Unicode character code (code point).

Returns

integerGlyph number.

Returns an array of glyph numbers corresponding to the Unicode characters.

glyphNumbersForCharacters(array $characterCodes) : array

If a particular character doesn't exist in this font, the special 'missing character glyph' will be substituted.

See also \glyphNumberForCharacter().

Parameters

$characterCodes

array

Array of Unicode character codes (code points).

Returns

arrayArray of glyph numbers.

Extracts a signed 2-byte integer from a string.

_extractInt2($data, integer $index) : integer

Integers are always big-endian. Throws an exception if the index is out of range.

Parameters

$data

$index

integer

Position in string of integer.

Exceptions

\Zend_Pdf_Exception

Returns

integer

Extracts an unsigned 2-byte integer from a string.

_extractUInt2($data, integer $index) : integer

Integers are always big-endian. Throws an exception if the index is out of range.

Parameters

$data

$index

integer

Position in string of integer.

Exceptions

\Zend_Pdf_Exception

Returns

integer

Extracts an unsigned 4-byte integer from a string.

_extractUInt4($data, integer $index) : integer

Integers are always big-endian. Throws an exception if the index is out of range.

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 or similar operators on large integers!

Parameters

$data

$index

integer

Position in string of integer.

Exceptions

\Zend_Pdf_Exception

Returns

integer

 Constants

 

Glyph representing missing characters.

MISSING_CHARACTER_GLYPH = 0 
 

Byte Encoding character map table type.

TYPE_BYTE_ENCODING = 0 
 

Static Byte Encoding character map table type. Variant of {@link TYPE_BYTEENCODING}.

TYPE_BYTE_ENCODING_STATIC = 241 
 

High Byte Mapping character map table type.

TYPE_HIGH_BYTE_MAPPING = 2 
 

Mixed Coverage character map table type.

TYPE_MIXED_COVERAGE = 8 
 

Segmented Coverage character map table type.

TYPE_SEGMENTED_COVERAGE = 12 
 

Segment Value to Delta Mapping character map table type.

TYPE_SEGMENT_TO_DELTA = 4 
 

Trimmed Array character map table type.

TYPE_TRIMMED_ARRAY = 10 
 

Trimmed Table character map table type.

TYPE_TRIMMED_TABLE = 6 
 

Unknown character map table type.

TYPE_UNKNOWN = 255