Pdf/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
- Fonts
- Version
- $Id: Font.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Pdf_Font
Font objects themselves are normally instantiated through the factory methods fontWithName() or fontWithPath().
This class is also the home for font-related constants because the name of the true base class (Zend_Pdf_Resource_Font) is not intuitive for the end user.
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants

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

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

FONT_COURIER_ITALIC
= 'Courier-Oblique'

FONT_COURIER_BOLD_OBLIQUE
= 'Courier-BoldOblique'

FONT_COURIER_BOLD_ITALIC
= 'Courier-BoldOblique'

FONT_HELVETICA_OBLIQUE
= 'Helvetica-Oblique'

FONT_HELVETICA_ITALIC
= 'Helvetica-Oblique'

FONT_HELVETICA_BOLD_OBLIQUE
= 'Helvetica-BoldOblique'

FONT_HELVETICA_BOLD_ITALIC
= 'Helvetica-BoldOblique'

FONT_TIMES
= 'Times-Roman'

FONT_TIMES_BOLD_ITALIC
= 'Times-BoldItalic'

NAME_POSTSCRIPT
= 6
This is the name used to identify fonts internally and within the PDF file.

NAME_DESCRIPTION
= 10
May contain revision information, usage recommendations, features, etc.

NAME_VENDOR_URL
= 11
Some fonts may contain a unique serial number embedded in this URL, which is used for licensing.

NAME_PREFERRED_FAMILY
= 16
Used by some fonts to work around a Microsoft Windows limitation where only four fonts styles can share the same NAME_FAMILY value.
Properties


array $_fontFilePaths = array()
The values are the font objects themselves.
array()
Details- Type
- array
Methods


_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.
Name | Type | Description |
---|---|---|
$dataSource | \Zend_Pdf_FileParserDataSource | |
$embeddingOptions | integer | Options for font embedding. |
Type | Description |
---|---|
\Zend_Pdf_Resource_Font_OpenType_TrueType | May also return null if the data source does not appear to contain a TrueType font. |
Exception | Description |
---|---|
\Zend_Pdf_Exception |


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 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.
Name | Type | Description |
---|---|---|
$name | string | Full PostScript name of font. |
$embeddingOptions | integer | (optional) Options for font embedding. |
Type | Description |
---|---|
\Zend_Pdf_Resource_Font |
Exception | Description |
---|---|
\Zend_Pdf_Exception |


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 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.
Name | Type | Description |
---|---|---|
$filePath | string | Full path to the font file. |
$embeddingOptions | integer | (optional) Options for font embedding. |
Type | Description |
---|---|
\Zend_Pdf_Resource_Font |
Exception | Description |
---|---|
\Zend_Pdf_Exception |