API Documentation

Pdf/FileParser/Font/OpenType.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Pdf
subpackage
FileParser
version
$Id: OpenType.php 20096 2010-01-06 02:05:09Z bkarwin $
Classes
Zend_Pdf_FileParser_Font_OpenType

Description

Zend Framework

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.

Zend_Pdf_FileParser_Font_OpenType

Extends from
Zend_Pdf_FileParser_Font
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Pdf
subpackage
FileParser
Properties
$_scalerType
$_tableDirectory
Methods
screen
parse
_parseTableDirectory
_parseHeadTable
_parseNameTable
_parsePostTable
_parseHheaTable
_parseMaxpTable
_parseOs2Table
_parseHmtxTable
_parseCmapTable
_readScalerType
_jumpToTable
_readTableVersion
_languageCodeForPlatform

Description

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:

  • {@link http://developer.apple.com/textfonts/TTRefMan/}
  • {@link http://www.microsoft.com/typography/OTSPEC/}
  • {@link http://partners.adobe.com/public/developer/opentype/index_spec.html}

Properties

$_scalerType

integer $_scalerType = '0'

Stores the scaler type (font type) for the font file. See {@link _readScalerType()}.

Details

$_scalerType
integer
visibility
protected
default
0
final
false
static
false

$_tableDirectory

array $_tableDirectory = 'array'

Stores the byte offsets to the various information tables.

Details

$_tableDirectory
array
visibility
protected
default
array
final
false
static
false

Methods

_jumpToTable

_jumpToTable( string $tableName ) :

Validates a given table's existence, then sets the file pointer to the start of that table.

Arguments
$tableName
string
Details
visibility
protected
final
false
static
false
throws

_languageCodeForPlatform

_languageCodeForPlatform( integer $platformID,  $languageID ) : string

Utility method that returns ISO 639 two-letter language codes from the TrueType platform and language ID. Returns NULL for languages that are not supported.

Arguments
$platformID
integer
$languageID
Output
string
| null
Details
visibility
protected
final
false
static
false

_parseCmapTable

_parseCmapTable( ) :

Parses the OpenType cmap (Character to Glyph Mapping) table.

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.

Details
visibility
protected
final
false
static
false
throws
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.

_parseHeadTable

_parseHeadTable( ) :

Parses the OpenType head (Font Header) table.

The head table contains global information about the font such as the revision number and global metrics.

Details
visibility
protected
final
false
static
false
throws

_parseHheaTable

_parseHheaTable( ) :

Parses the OpenType hhea (Horizontal Header) table.

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.

Details
visibility
protected
final
false
static
false
throws

_parseHmtxTable

_parseHmtxTable( ) :

Parses the OpenType hmtx (Horizontal Metrics) table.

The hmtx table contains the horizontal metrics for every glyph contained within the font. These are the critical values for horizontal layout of text.

Details
visibility
protected
final
false
static
false
throws

_parseMaxpTable

_parseMaxpTable( ) :

Parses the OpenType hhea (Horizontal Header) table.

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.

Details
visibility
protected
final
false
static
false
throws

_parseNameTable

_parseNameTable( ) :

Parses the OpenType name (Naming) table.

The name table contains all of the identifying strings associated with the font such as its name, copyright, trademark, license, etc.

Details
visibility
protected
final
false
static
false
throws

_parseOs2Table

_parseOs2Table( ) :

Parses the OpenType OS/2 (OS/2 and Windows Metrics) table.

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.

Details
visibility
protected
final
false
static
false
throws

_parsePostTable

_parsePostTable( ) :

Parses the OpenType post (PostScript Information) table.

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.

Details
visibility
protected
final
false
static
false
throws

_parseTableDirectory

_parseTableDirectory( ) :

Parses the OpenType table directory.

The table directory contains the identifier, checksum, byte offset, and length of each of the information tables housed in the font file.

Details
visibility
protected
final
false
static
false
throws

_readScalerType

_readScalerType( ) : integer

Reads the scaler type from the header of the OpenType font file and returns it as an unsigned long 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.

Output
integer
Details
visibility
protected
final
false
static
false
throws

_readTableVersion

_readTableVersion( float $minVersion,  $maxVersion ) : float

Reads the fixed 16.16 table version number and checks for compatibility.

If the version is incompatible, throws an exception. If it is compatible, returns the version number.

Arguments
$minVersion
float
Minimum compatible version number.
$maxVersion
Output
float
Table version number.
Details
visibility
protected
final
false
static
false
throws

parse

parse( ) :

Reads and parses the font data from the file on disk.

NOTE: This method should be overridden in subclasses to add type- specific parsing and set $this->isParsed.

Details
visibility
public
final
false
static
false
throws

screen

screen( ) :

Verifies that the font file is in the expected format.

NOTE: This method should be overridden in subclasses to check the specific format and set $this->_isScreened!

Details
visibility
public
final
false
static
false
throws
Documentation was generated by DocBlox.