## Zend_Pdf_Resource_Font

Description

Abstract class which manages PDF fonts.

Defines the public interface and creates shared storage for concrete subclasses which are responsible for generating the font's information dictionaries, mapping characters to glyphs, and providing both overall font and glyph-specific metric data.

Font objects should be normally be obtained from the factory methods Zend_Pdf_Font::fontWithName and Zend_Pdf_Font::fontWithPath.

- abstract:
- license: New BSD License
- copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)

Located in /Zend/Pdf/Resource/Font.php (line 50)

    Zend_Pdf_Resource
       |
       --Zend_Pdf_Resource_Font

Direct descendents

Class | Description
--- | ---
Zend_Pdf_Resource_Font_OpenType | OpenType fonts implementation
Zend_Pdf_Resource_Font_Standard | Abstract class definition for the standard 14 Type 1 PDF fonts.

Variable Summary
Zend_Pdf_Cmap $cmap
integer $_ascent
integer $_descent
array $_fontNames
integer $_fontType
integer $_glyphMaxIndex
array $_glyphWidths
boolean $_isBold
boolean $_isItalic
boolean $_isMonospace
integer $_lineGap
integer $_strikePosition
integer $_strikeThickness
integer $_underlinePosition
integer $_underlineThickness
integer $_unitsPerEm
Method Summary
Zend_Pdf_Resource_Font __construct ([integer $embeddingOptions = 0])
string decodeString (string $string, string $charEncoding)
string encodeString (string $string, string $charEncoding)
integer getAscent ()
float getCoveredPercentage (string $string, [string $charEncoding = ''])
integer getDescent ()
string getFontName (integer $nameType, mixed $language, [string $characterSet = null])
integer getFontType ()
integer getLineGap ()
integer getLineHeight ()
integer getStrikePosition ()
integer getStrikeThickness ()
integer getUnderlinePosition ()
integer getUnderlineThickness ()
integer getUnitsPerEm ()
integer widthForGlyph (integer $glyphNumber)
array widthsForGlyphs (array &$glyphNumbers)
boolean _isEmbeddingOptionSet (integer $embeddingOption)
integer _toEmSpace (integer $value)
string __toString ()
Variables
Zend_Pdf_Cmap $cmap = null (line 59)

Object representing the font's cmap (character to glyph map).

- access: public

integer $_ascent = 0 (line 125)

Typographical ascent. See getAscent().

- access: protected

integer $_descent = 0 (line 131)

Typographical descent. See getDescent().

- access: protected

array $_fontNames = array() (line 71)

Array containing descriptive names for the font. See fontName().

- access: protected

integer $_fontType = Zend_Pdf_Font::TYPE_UNKNOWN (line 65)

The type of font. Use TYPE_ constants defined in Zend_Pdf_Font.

- access: protected

integer $_glyphMaxIndex = 0 (line 149)

The highest integer index in the glyph widths array.

- access: protected

array $_glyphWidths = null (line 143)

Array containing the widths of each of the glyphs contained in the font.

- access: protected

boolean $_isBold = false (line 77)

Flag indicating whether or not this font is bold.

- access: protected

boolean $_isItalic = false (line 83)

Flag indicating whether or not this font is italic.

- access: protected

boolean $_isMonospace = false (line 89)

Flag indicating whether or not this font is monospaced.

- access: protected

integer $_lineGap = 0 (line 137)

Typographical line gap. See getLineGap().

- access: protected

integer $_strikePosition = 0 (line 107)

The position above the text baseline of the strikethrough (in glyph units).

- access: protected

integer $_strikeThickness = 0 (line 113)

The thickness of the strikethrough (in glyph units).

- access: protected

integer $_underlinePosition = 0 (line 95)

The position below the text baseline of the underline (in glyph units).

- access: protected

integer $_underlineThickness = 0 (line 101)

The thickness of the underline (in glyph units).

- access: protected

integer $_unitsPerEm = 0 (line 119)

Number of glyph units per em. See getUnitsPerEm().

- access: protected

#### Inherited Variables

Inherited from Zend_Pdf_Resource

> Zend_Pdf_Resource::$_objectFactory
> Zend_Pdf_Resource::$_resource

Methods
Constructor __construct (line 175)

Object constructor.

The $embeddingOptions parameter allows you to set certain flags related to font embedding. You may combine options by OR-ing them together. See the EMBED_ constants defined in Zend_Pdf_Font for the list of available options and their descriptions.

- access: public

Zend_Pdf_Resource_Font __construct (integer $embeddingOptions)

- integer $embeddingOptions: (optional) Options for font embedding. Only used for certain font types.

Redefinition of:

Zend_Pdf_Resource::__construct()
  Object constructor.

Redefined in descendants as:

- Zend_Pdf_Resource_Font_OpenType::__construct() : Object constructor
- Zend_Pdf_Resource_Font_OpenType_TrueType::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_Courier::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_CourierBold::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_CourierBoldOblique::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_CourierOblique::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_Helvetica::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_HelveticaBold::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_HelveticaBoldOblique::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_HelveticaOblique::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_Symbol::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_TimesBold::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_TimesBoldItalic::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_TimesItalic::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_TimesRoman::__construct() : Object constructor
- Zend_Pdf_Resource_Font_Standard_ZapfDingbats::__construct() : Object constructor

decodeString (line 541)

Convert string from Windows ANSI encoding to local encoding.

NOTE: This method may disappear in a future revision of the framework once the font subsetting and Unicode support code is complete. At that point, there may be multiple ways of encoding strings depending on intended usage. You should treat this method as framework internal use only.

- access: public

string decodeString (string $string, string $charEncoding)

- string $string
- string $charEncoding: Character encoding of resulting text.

Redefined in descendants as:

- Zend_Pdf_Resource_Font_Standard_Symbol::decodeString() : Convert string encoding from font encoding to local encoding. Overridden to defeat the conversion behavior for this ornamental font.
- Zend_Pdf_Resource_Font_Standard_ZapfDingbats::decodeString() : Convert string encoding from font encoding to local encoding. Overridden to defeat the conversion behavior for this ornamental font.

encodeString (line 519)

Convert string from local encoding to Windows ANSI encoding.

NOTE: This method may disappear in a future revision of the framework once the font subsetting and Unicode support code is complete. At that point, there may be multiple ways of encoding strings depending on intended usage. You should treat this method as framework internal use only.

- access: public

string encodeString (string $string, string $charEncoding)

- string $string
- string $charEncoding: Character encoding of source text.

Redefined in descendants as:

- Zend_Pdf_Resource_Font_Standard_Symbol::encodeString() : Convert string encoding from local encoding to font encoding. Overridden to defeat the conversion behavior for this ornamental font.
- Zend_Pdf_Resource_Font_Standard_ZapfDingbats::encodeString() : Convert string encoding from local encoding to font encoding. Overridden to defeat the conversion behavior for this ornamental font.

getAscent (line 353)

Returns the typographic ascent in font glyph units.

The typographic ascent is the distance from the font's baseline to the top of the text frame. It is frequently used to locate the initial baseline for a paragraph of text inside a given rectangle.

- access: public

integer getAscent ()
getCoveredPercentage (line 425)

Returns a number between 0 and 1 inclusive that indicates the percentage of characters in the string which are covered by glyphs in this font.

Since no one font will contain glyphs for the entire Unicode character range, this method can be used to help locate a suitable font when the actual contents of the string are not known.

Note that some fonts lie about the characters they support. Additionally, fonts don't usually contain glyphs for control characters such as tabs and line breaks, so it is rare that you will get back a full 1.0 score. The resulting value should be considered informational only.

- access: public

float getCoveredPercentage (string $string, [string $charEncoding = ''])

- string $string
- string $charEncoding: (optional) Character encoding of source text. If omitted, uses 'current locale'.

getDescent (line 366)

Returns the typographic descent in font glyph units.

The typographic descent is the distance below the font's baseline to the bottom of the text frame. It is always negative.

- access: public

integer getDescent ()
getFontName (line 256)

Returns the specified descriptive name for the font.

The font name type is usually one of the following:

- Zend_Pdf_Font::NAME_FULL
- Zend_Pdf_Font::NAME_FAMILY
- Zend_Pdf_Font::NAME_PREFERRED_FAMILY
- Zend_Pdf_Font::NAME_STYLE
- Zend_Pdf_Font::NAME_PREFERRED_STYLE
- Zend_Pdf_Font::NAME_DESCRIPTION
- Zend_Pdf_Font::NAME_SAMPLETEXT
- Zend_Pdf_Font::NAME_ID
- Zend_Pdf_Font::NAME_VERSION
- Zend_Pdf_Font::NAME_POSTSCRIPT
- Zend_Pdf_Font::NAME_CID_NAME
- Zend_Pdf_Font::NAME_DESIGNER
- Zend_Pdf_Font::NAME_DESIGNER_URL
- Zend_Pdf_Font::NAME_MANUFACTURER
- Zend_Pdf_Font::NAME_VENDOR_URL
- Zend_Pdf_Font::NAME_COPYRIGHT
- Zend_Pdf_Font::NAME_TRADEMARK
- Zend_Pdf_Font::NAME_LICENSE
- Zend_Pdf_Font::NAME_LICENSE_URL

Note that not all names are available for all fonts. In addition, some fonts may contain additional names, whose indicies are in the range 256 to 32767 inclusive, which are used for certain font layout features.

If the preferred language translation is not available, uses the first available translation for the name, which is usually English.

If the requested name does not exist, returns null.

All names are stored internally as Unicode strings, using UTF-16BE encoding. You may optionally supply a different resulting character set.

- access: public

string getFontName (integer $nameType, mixed $language, [string $characterSet = null])

- integer $nameType: Type of name requested.
- mixed $language: Preferred language (string) or array of languages in preferred order. Use the ISO 639 standard 2-letter language codes.
- string $characterSet: (optional) Desired resulting character set. You may use any character set supported by http://www.php.net/iconv;

getFontType (line 206)

Returns the type of font.

- return: One of the TYPE_ constants defined in Zend_Pdf_Font.
- access: public

integer getFontType ()
getLineGap (line 381)

Returns the typographic line gap in font glyph units.

The typographic line gap is the distance between the bottom of the text frame of one line to the top of the text frame of the next. It is typically combined with the typographical ascent and descent to determine the font's total line height (or leading).

- access: public

integer getLineGap ()
getLineHeight (line 399)

Returns the suggested line height (or leading) in font glyph units.

This value is determined by adding together the values of the typographic ascent, descent, and line gap. This value yields the suggested line spacing as determined by the font developer.

It should be noted that this is only a guideline; layout engines will frequently modify this value to achieve special effects such as double- spacing.

- access: public

integer getLineHeight ()
getStrikePosition (line 316)

Returns the suggested position above the text baseline of the strikethrough in glyph units.

- access: public

integer getStrikePosition ()
getStrikeThickness (line 326)

Returns the suggested line thickness of the strikethrough in glyph units.

- access: public

integer getStrikeThickness ()
getUnderlinePosition (line 295)

Returns the suggested position below the text baseline of the underline in glyph units.

This value is usually negative.

- access: public

integer getUnderlinePosition ()
getUnderlineThickness (line 305)

Returns the suggested line thickness of the underline in glyph units.

- access: public

integer getUnderlineThickness ()
getUnitsPerEm (line 339)

Returns the number of glyph units per em.

Used to convert glyph space to user space. Frequently used in conjunction with widthsForGlyphs() to calculate the with of a run of text.

- access: public

integer getUnitsPerEm ()
widthForGlyph (line 497)

Returns the width of the glyph.

Like widthsForGlyphs() but used for one glyph at a time.

- access: public
- throws: Zend_Pdf_Exception

integer widthForGlyph (integer $glyphNumber)

- integer $glyphNumber

widthsForGlyphs (line 475)

Returns the widths of the glyphs.

The widths are expressed in the font's glyph space. You are responsible for converting to user space as necessary. See {$link unitsPerEm()}.

Throws an exception if the glyph number is out of range.

See also widthForGlyph().

- return: Array of glyph widths (integers).
- access: public
- throws: Zend_Pdf_Exception

array widthsForGlyphs (array &$glyphNumbers)

- array &$glyphNumbers: Array of glyph numbers.

_isEmbeddingOptionSet (line 576)

Returns true if the embedding option has been set for this font.

The embedding options are stored as a bitfield. Multiple options may be set at the same time.

This is only used by certain subclasses.

- access: protected

boolean _isEmbeddingOptionSet (integer $embeddingOption)

- integer $embeddingOption

_toEmSpace (line 557)

If the font's glyph space is not 1000 units per em, converts the value.

- access: protected

integer _toEmSpace (integer $value)

- integer $value

__toString (line 192)

Returns the full name of the font in the encoding method of the current locale. Transliterates any characters that cannot be naturally represented in that character set.

- access: public

string __toString ()

#### Inherited Methods

Inherited From Zend_Pdf_Resource

> Zend_Pdf_Resource::__construct()
> Zend_Pdf_Resource::getResource()

Documentation generated on Wed, 21 Feb 2007 11:48:36 -0800 by phpDocumentor 1.3.1