API Documentation

Pdf/Font.php

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
Fonts
version
$Id: Font.php 20211 2010-01-12 02:14:29Z yoshida@zend.co.jp $
Classes
Zend_Pdf_Font

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_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
Fonts
Constants
TYPE_UNKNOWN
TYPE_STANDARD
TYPE_TYPE_1
TYPE_TRUETYPE
TYPE_TYPE_0
TYPE_CIDFONT_TYPE_0
TYPE_CIDFONT_TYPE_2
FONT_COURIER
FONT_COURIER_BOLD
FONT_COURIER_OBLIQUE
FONT_COURIER_ITALIC
FONT_COURIER_BOLD_OBLIQUE
FONT_COURIER_BOLD_ITALIC
FONT_HELVETICA
FONT_HELVETICA_BOLD
FONT_HELVETICA_OBLIQUE
FONT_HELVETICA_ITALIC
FONT_HELVETICA_BOLD_OBLIQUE
FONT_HELVETICA_BOLD_ITALIC
FONT_SYMBOL
FONT_TIMES_ROMAN
FONT_TIMES
FONT_TIMES_BOLD
FONT_TIMES_ITALIC
FONT_TIMES_BOLD_ITALIC
FONT_ZAPFDINGBATS
NAME_COPYRIGHT
NAME_FAMILY
NAME_STYLE
NAME_ID
NAME_FULL
NAME_VERSION
NAME_POSTSCRIPT
NAME_TRADEMARK
NAME_MANUFACTURER
NAME_DESIGNER
NAME_DESCRIPTION
NAME_VENDOR_URL
NAME_DESIGNER_URL
NAME_LICENSE
NAME_LICENSE_URL
NAME_PREFERRED_FAMILY
NAME_PREFERRED_STYLE
NAME_SAMPLE_TEXT
NAME_CID_NAME
WEIGHT_THIN
WEIGHT_EXTRA_LIGHT
WEIGHT_LIGHT
WEIGHT_NORMAL
WEIGHT_MEDIUM
WEIGHT_SEMI_BOLD
WEIGHT_BOLD
WEIGHT_EXTRA_BOLD
WEIGHT_BLACK
WIDTH_ULTRA_CONDENSED
WIDTH_EXTRA_CONDENSED
WIDTH_CONDENSED
WIDTH_SEMI_CONDENSED
WIDTH_NORMAL
WIDTH_SEMI_EXPANDED
WIDTH_EXPANDED
WIDTH_EXTRA_EXPANDED
WIDTH_ULTRA_EXPANDED
EMBED_DONT_EMBED
EMBED_DONT_SUBSET
EMBED_DONT_COMPRESS
EMBED_SUPPRESS_EMBED_EXCEPTION
Properties
$_fontNames
$_fontFilePaths
Methods
fontWithName
fontWithPath
_extractTrueTypeFont

Description

Abstract factory class which vends {@link Zend_Pdf_Resource_Font} objects.

Font objects themselves are normally instantiated through the factory methods {@link fontWithName()} or {@link fontWithPath()}.

This class is also the home for font-related constants because the name of the true base class ({@link Zend_Pdf_Resource_Font}) is not intuitive for the end user.

Constants

TYPE_UNKNOWN

 TYPE_UNKNOWN = '0'

Unknown font type.

Details

value
0

TYPE_STANDARD

 TYPE_STANDARD = '1'

One of the standard 14 PDF fonts.

Details

value
1

TYPE_TYPE_1

 TYPE_TYPE_1 = '2'

A PostScript Type 1 font.

Details

value
2

TYPE_TRUETYPE

 TYPE_TRUETYPE = '3'

A TrueType font or an OpenType font containing TrueType outlines.

Details

value
3

TYPE_TYPE_0

 TYPE_TYPE_0 = '4'

Type 0 composite font.

Details

value
4

TYPE_CIDFONT_TYPE_0

 TYPE_CIDFONT_TYPE_0 = '5'

CID font containing a PostScript Type 1 font.

These fonts are used only to construct Type 0 composite fonts and can't be used directly

Details

value
5

TYPE_CIDFONT_TYPE_2

 TYPE_CIDFONT_TYPE_2 = '6'

CID font containing a TrueType font or an OpenType font containing TrueType outlines.

These fonts are used only to construct Type 0 composite fonts and can't be used directly

Details

value
6

FONT_COURIER

 FONT_COURIER = 'Courier'

Name of the standard PDF font Courier.

Details

value
Courier

FONT_COURIER_BOLD

 FONT_COURIER_BOLD = 'Courier-Bold'

Name of the bold style of the standard PDF font Courier.

Details

value
Courier-Bold

FONT_COURIER_OBLIQUE

 FONT_COURIER_OBLIQUE = 'Courier-Oblique'

Name of the italic style of the standard PDF font Courier.

Details

value
Courier-Oblique

FONT_COURIER_ITALIC

 FONT_COURIER_ITALIC = 'Courier-Oblique'

Convenience constant for a common misspelling of {@link FONT_COURIER_OBLIQUE}.

Details

value
Courier-Oblique

FONT_COURIER_BOLD_OBLIQUE

 FONT_COURIER_BOLD_OBLIQUE = 'Courier-BoldOblique'

Name of the bold and italic style of the standard PDF font Courier.

Details

value
Courier-BoldOblique

FONT_COURIER_BOLD_ITALIC

 FONT_COURIER_BOLD_ITALIC = 'Courier-BoldOblique'

Convenience constant for a common misspelling of {@link FONT_COURIER_BOLD_OBLIQUE}.

Details

value
Courier-BoldOblique

FONT_HELVETICA

 FONT_HELVETICA = 'Helvetica'

Name of the standard PDF font Helvetica.

Details

value
Helvetica

FONT_HELVETICA_BOLD

 FONT_HELVETICA_BOLD = 'Helvetica-Bold'

Name of the bold style of the standard PDF font Helvetica.

Details

value
Helvetica-Bold

FONT_HELVETICA_OBLIQUE

 FONT_HELVETICA_OBLIQUE = 'Helvetica-Oblique'

Name of the italic style of the standard PDF font Helvetica.

Details

value
Helvetica-Oblique

FONT_HELVETICA_ITALIC

 FONT_HELVETICA_ITALIC = 'Helvetica-Oblique'

Convenience constant for a common misspelling of {@link FONT_HELVETICA_OBLIQUE}.

Details

value
Helvetica-Oblique

FONT_HELVETICA_BOLD_OBLIQUE

 FONT_HELVETICA_BOLD_OBLIQUE = 'Helvetica-BoldOblique'

Name of the bold and italic style of the standard PDF font Helvetica.

Details

value
Helvetica-BoldOblique

FONT_HELVETICA_BOLD_ITALIC

 FONT_HELVETICA_BOLD_ITALIC = 'Helvetica-BoldOblique'

Convenience constant for a common misspelling of {@link FONT_HELVETICA_BOLD_OBLIQUE}.

Details

value
Helvetica-BoldOblique

FONT_SYMBOL

 FONT_SYMBOL = 'Symbol'

Name of the standard PDF font Symbol.

Details

value
Symbol

FONT_TIMES_ROMAN

 FONT_TIMES_ROMAN = 'Times-Roman'

Name of the standard PDF font Times.

Details

value
Times-Roman

FONT_TIMES

 FONT_TIMES = 'Times-Roman'

Convenience constant for a common misspelling of {@link FONT_TIMES_ROMAN}.

Details

value
Times-Roman

FONT_TIMES_BOLD

 FONT_TIMES_BOLD = 'Times-Bold'

Name of the bold style of the standard PDF font Times.

Details

value
Times-Bold

FONT_TIMES_ITALIC

 FONT_TIMES_ITALIC = 'Times-Italic'

Name of the italic style of the standard PDF font Times.

Details

value
Times-Italic

FONT_TIMES_BOLD_ITALIC

 FONT_TIMES_BOLD_ITALIC = 'Times-BoldItalic'

Name of the bold and italic style of the standard PDF font Times.

Details

value
Times-BoldItalic

FONT_ZAPFDINGBATS

 FONT_ZAPFDINGBATS = 'ZapfDingbats'

Name of the standard PDF font Zapf Dingbats.

Details

value
ZapfDingbats

NAME_COPYRIGHT

 NAME_COPYRIGHT = '0'

Full copyright notice for the font.

Details

value
0

NAME_FAMILY

 NAME_FAMILY = '1'

Font family name. Used to group similar styles of fonts together.

Details

value
1

NAME_STYLE

 NAME_STYLE = '2'

Font style within the font family. Examples: Regular, Italic, Bold, etc.

Details

value
2

NAME_ID

 NAME_ID = '3'

Unique font identifier.

Details

value
3

NAME_FULL

 NAME_FULL = '4'

Full font name. Usually a combination of the {@link NAME_FAMILY} and {@link NAME_STYLE} strings.

Details

value
4

NAME_VERSION

 NAME_VERSION = '5'

Version number of the font.

Details

value
5

NAME_POSTSCRIPT

 NAME_POSTSCRIPT = '6'

PostScript name for the font. This is the name used to identify fonts internally and within the PDF file.

Details

value
6

NAME_TRADEMARK

 NAME_TRADEMARK = '7'

Font trademark notice. This is distinct from the {@link NAME_COPYRIGHT}.

Details

value
7

NAME_MANUFACTURER

 NAME_MANUFACTURER = '8'

Name of the font manufacturer.

Details

value
8

NAME_DESIGNER

 NAME_DESIGNER = '9'

Name of the designer of the font.

Details

value
9

NAME_DESCRIPTION

 NAME_DESCRIPTION = '10'

Description of the font. May contain revision information, usage recommendations, features, etc.

Details

value
10

NAME_VENDOR_URL

 NAME_VENDOR_URL = '11'

URL of the font vendor. Some fonts may contain a unique serial number embedded in this URL, which is used for licensing.

Details

value
11

NAME_DESIGNER_URL

 NAME_DESIGNER_URL = '12'

URL of the font designer ({@link NAME_DESIGNER}).

Details

value
12

NAME_LICENSE

 NAME_LICENSE = '13'

Plain language licensing terms for the font.

Details

value
13

NAME_LICENSE_URL

 NAME_LICENSE_URL = '14'

URL of more detailed licensing information for the font.

Details

value
14

NAME_PREFERRED_FAMILY

 NAME_PREFERRED_FAMILY = '16'

Preferred font family. Used by some fonts to work around a Microsoft Windows limitation where only four fonts styles can share the same {@link NAME_FAMILY} value.

Details

value
16

NAME_PREFERRED_STYLE

 NAME_PREFERRED_STYLE = '17'

Preferred font style. A more descriptive string than {@link NAME_STYLE}.

Details

value
17

NAME_SAMPLE_TEXT

 NAME_SAMPLE_TEXT = '19'

Suggested text to use as a representative sample of the font.

Details

value
19

NAME_CID_NAME

 NAME_CID_NAME = '20'

PostScript CID findfont name.

Details

value
20

WEIGHT_THIN

 WEIGHT_THIN = '100'

Thin font weight.

Details

value
100

WEIGHT_EXTRA_LIGHT

 WEIGHT_EXTRA_LIGHT = '200'

Extra-light (Ultra-light) font weight.

Details

value
200

WEIGHT_LIGHT

 WEIGHT_LIGHT = '300'

Light font weight.

Details

value
300

WEIGHT_NORMAL

 WEIGHT_NORMAL = '400'

Normal (Regular) font weight.

Details

value
400

WEIGHT_MEDIUM

 WEIGHT_MEDIUM = '500'

Medium font weight.

Details

value
500

WEIGHT_SEMI_BOLD

 WEIGHT_SEMI_BOLD = '600'

Semi-bold (Demi-bold) font weight.

Details

value
600

WEIGHT_BOLD

 WEIGHT_BOLD = '700'

Bold font weight.

Details

value
700

WEIGHT_EXTRA_BOLD

 WEIGHT_EXTRA_BOLD = '800'

Extra-bold (Ultra-bold) font weight.

Details

value
800

WEIGHT_BLACK

 WEIGHT_BLACK = '900'

Black (Heavy) font weight.

Details

value
900

WIDTH_ULTRA_CONDENSED

 WIDTH_ULTRA_CONDENSED = '1'

Ultra-condensed font width. Typically 50% of normal.

Details

value
1

WIDTH_EXTRA_CONDENSED

 WIDTH_EXTRA_CONDENSED = '2'

Extra-condensed font width. Typically 62.5% of normal.

Details

value
2

WIDTH_CONDENSED

 WIDTH_CONDENSED = '3'

Condensed font width. Typically 75% of normal.

Details

value
3

WIDTH_SEMI_CONDENSED

 WIDTH_SEMI_CONDENSED = '4'

Semi-condensed font width. Typically 87.5% of normal.

Details

value
4

WIDTH_NORMAL

 WIDTH_NORMAL = '5'

Normal (Medium) font width.

Details

value
5

WIDTH_SEMI_EXPANDED

 WIDTH_SEMI_EXPANDED = '6'

Semi-expanded font width. Typically 112.5% of normal.

Details

value
6

WIDTH_EXPANDED

 WIDTH_EXPANDED = '7'

Expanded font width. Typically 125% of normal.

Details

value
7

WIDTH_EXTRA_EXPANDED

 WIDTH_EXTRA_EXPANDED = '8'

Extra-expanded font width. Typically 150% of normal.

Details

value
8

WIDTH_ULTRA_EXPANDED

 WIDTH_ULTRA_EXPANDED = '9'

Ultra-expanded font width. Typically 200% of normal.

Details

value
9

EMBED_DONT_EMBED

 EMBED_DONT_EMBED = '0x01'

Do not embed the font in the PDF document.

Details

value
0x01

EMBED_DONT_SUBSET

 EMBED_DONT_SUBSET = '0x02'

Embed, but do not subset the font in the PDF document.

Details

value
0x02

EMBED_DONT_COMPRESS

 EMBED_DONT_COMPRESS = '0x04'

Embed, but do not compress the font in the PDF document.

Details

value
0x04

EMBED_SUPPRESS_EMBED_EXCEPTION

 EMBED_SUPPRESS_EMBED_EXCEPTION = '0x08'

Suppress the exception normally thrown if the font cannot be embedded due to its copyright bits being set.

Details

value
0x08

Properties

$_fontFilePaths

array $_fontFilePaths = 'array'

Array whose keys are the md5 hash of the full paths on disk for parsed fonts. The values are the font objects themselves.

Details

$_fontFilePaths
array
visibility
private
default
array
final
false
static
true

$_fontNames

array $_fontNames = 'array'

Array whose keys are the unique PostScript names of instantiated fonts.

The values are the font objects themselves.

Details

$_fontNames
array
visibility
private
default
array
final
false
static
true

Methods

_extractTrueTypeFont

_extractTrueTypeFont( Zend_Pdf_FileParserDataSource $dataSource, integer $embeddingOptions ) : Zend_Pdf_Resource_Font_OpenType_TrueType

Attempts to extract a TrueType font from the data source.

If the font parser throws an exception that suggests the data source simply doesn't contain a TrueType font, catches it and returns null. If an exception is thrown that suggests the TrueType font is corrupt or otherwise unusable, throws that exception. If successful, returns the font object.

Arguments
$dataSource
Zend_Pdf_FileParserDataSource
$embeddingOptions
integer
Options for font embedding.
Output
Zend_Pdf_Resource_Font_OpenType_TrueType
May also return null if the data source does not appear to contain a TrueType font.
Details
visibility
protected
final
false
static
true
throws

fontWithName

fontWithName( string $name, integer $embeddingOptions = 0 ) : Zend_Pdf_Resource_Font

Returns a {@link Zend_Pdf_Resource_Font} object by full name.

This is the preferred method to obtain one of the standard 14 PDF fonts.

The result of this method is cached, preventing unnecessary duplication of font objects. Repetitive calls for a font with the same name will return the same object.

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 {@link Zend_Pdf_Font} for the list of available options and their descriptions. Note that this value is only used when creating a font for the first time. If a font with the same name already exists, you will get that object and the options you specify here will be ignored. This is because fonts are only embedded within the PDF file once.

If the font name supplied does not match the name of a previously instantiated object and it is not one of the 14 standard PDF fonts, an exception will be thrown.

Arguments
$name
string
Full PostScript name of font.
$embeddingOptions
integer
(optional) Options for font embedding.
Details
visibility
public
final
false
static
true
throws

fontWithPath

fontWithPath( string $filePath, integer $embeddingOptions = 0 ) : Zend_Pdf_Resource_Font

Returns a {@link Zend_Pdf_Resource_Font} object by file path.

The result of this method is cached, preventing unnecessary duplication of font objects. Repetitive calls for the font with the same path will return the same object.

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 {@link Zend_Pdf_Font} for the list of available options and their descriptions. Note that this value is only used when creating a font for the first time. If a font with the same name already exists, you will get that object and the options you specify here will be ignored. This is because fonts are only embedded within the PDF file once.

If the file path supplied does not match the path of a previously instantiated object or the font type cannot be determined, an exception will be thrown.

Arguments
$filePath
string
Full path to the font file.
$embeddingOptions
integer
(optional) Options for font embedding.
Details
visibility
public
final
false
static
true
throws
Documentation was generated by DocBlox.