SetaPDF_Core_Font_Type1 Class for Type1 fonts

File: /SetaPDF v2/Core/Font/Type1.php

Class hierarchy

Implements

Summary

Constants

INFO_COPYRIGHT

public const string SetaPDF_Core_Font::INFO_COPYRIGHT = 'copyright'

Info constant

INFO_CREATION_DATE

public const string SetaPDF_Core_Font::INFO_CREATION_DATE = 'creationDate'

Info constant

INFO_UNIQUE_ID

public const string SetaPDF_Core_Font::INFO_UNIQUE_ID = 'uniqueId'

Info constant

INFO_VERSION

public const string SetaPDF_Core_Font::INFO_VERSION = 'version'

Info constant

TYPE_COLOR_SPACE

public const string SetaPDF_Core_Resource::TYPE_COLOR_SPACE = 'ColorSpace'

Type constant

TYPE_EXT_G_STATE

public const string SetaPDF_Core_Resource::TYPE_EXT_G_STATE = 'ExtGState'

Type constant

TYPE_FONT

public const string SetaPDF_Core_Resource::TYPE_FONT = 'Font'

Type constant

TYPE_PATTERN

public const string SetaPDF_Core_Resource::TYPE_PATTERN = 'Pattern'

Type constant

TYPE_PROC_SET

public const string SetaPDF_Core_Resource::TYPE_PROC_SET = 'ProcSet'

Type constant

TYPE_PROPERTIES

public const string SetaPDF_Core_Resource::TYPE_PROPERTIES = 'Properties'

Type constant

TYPE_SHADING

public const string SetaPDF_Core_Resource::TYPE_SHADING = 'Shading'

Type constant

TYPE_X_OBJECT

public const string SetaPDF_Core_Resource::TYPE_X_OBJECT = 'XObject'

Type constant


Properties

$_avgWidth

protected integer|float SetaPDF_Core_Font_Simple::$_avgWidth

The average width of glyphs in the font.

$_charCodeCache

protected array SetaPDF_Core_Font::$_charCodeCache = array()

A char code cache which is used in SetaPDF_Core_Font::getCharByCharCode().

$_dictionary

$_encodingTable

The encoding table

$_fontBBox

protected null|array SetaPDF_Core_Font_Type1::$_fontBBox

The font bounding box

$_fontBBoxVector

$_fontDescriptor

The font descriptor object

$_indirectObject

The indirect object of the font

$_info

protected array SetaPDF_Core_Font::$_info = array()

Array holding information about the font

$_substituteCharacter

The UTF-16BE unicode value for a substitute character

$_toUnicodeTable

The map that maps character codes to uncidoe values

$_underlinePosition

protected null|int|float SetaPDF_Core_Font::$_underlinePosition

The relative underline positioning.

$_underlineThickness

protected null|int|float SetaPDF_Core_Font::$_underlineThickness

The underline thickness.

$_widths

protected null|array SetaPDF_Core_Font_Type1::$_widths

Glyph widths

$_widthsByCharCode

Widths by char codes


Static Methods

freeCache()

public static SetaPDF_Core_Font::freeCache (): void

Release font instances by a document instance.

Parameters
$document : SetaPDF_Core_Document
 

freeFontCache()

public static SetaPDF_Core_Font::freeFontCache (): void

Release font instances by a document instance.

Parameters
$document : SetaPDF_Core_Document
 
See

get()

public static SetaPDF_Core_Font::get (
$indirectObjectOrDictionary
):

Get a font object by an indirect reference.

The needed font object class is automatically resolve via the Subtype value of the font dictionary.

Parameters
$indirectObjectOrDictionary
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Core_Type_Exception


Methods

__construct()

public SetaPDF_Core_Font_Type1::__construct (
$indirectObjectOrDictionary
)

The constructor.

Parameters
$indirectObjectOrDictionary
 
Exceptions

Throws SetaPDF_Core_Font_Exception

_ensureUnderlinePosition()

Calculates the underline position.

This method is only used if no underline thickness is provided by the font implementation (e.g. through an already embedded font). We simply use the font bounding box to calculate a meaningful value.

_ensureUnderlineThickness()

Calculates the underline thickness.

This method is only used if no underline thickness is provided by the font implementation (e.g. through an already embedded font).

_getCharCodesTable()

Get the map that maps character codes to unicode values.

Exceptions

Throws SetaPDF_Core_Font_Exception

_getEncodingTable()

Get the encoding table based on the Encoding dictionary and it's Differences entry (if available).

_getWidths()

protected SetaPDF_Core_Font_Type1::_getWidths (
void
): void

Resolves the width values from the font descriptor and fills the $_width-array.

getAscent()

Returns the distance from baseline of highest ascender (Typographic ascent).

getAvgWidth()

public SetaPDF_Core_Font_Type1::getAvgWidth (
[ $calculateIfUndefined = false ]
):

Get the average glyph width.

Parameters
$calculateIfUndefined
 

getBaseEncodingTable()

Get the base encoding of the font.

If no BaseEncoding entry is available we use the Standard encoding for now. This should be extended to get the fonts build in encoding later.

getCharByCharCode()

public SetaPDF_Core_Font::getCharByCharCode (
$charCode [, $encoding = 'UTF-8' ]
):

Converts a char code from the font specific encoding to another encoding.

Parameters
$charCode

The char code in the font specific encoding.

$encoding

The resulting encoding

getCharCode()

public SetaPDF_Core_Font::getCharCode (
$char [, $encoding = 'UTF-16BE' ]
):

Get the final character code of a single character.

Parameters
$char

The character

$encoding

The output encoding

getCharCodes()

public SetaPDF_Core_Font::getCharCodes (
$chars [, $encoding = 'UTF-16BE' ]
):

Get the final character codes of a character string.

Parameters
$chars

The character string

$encoding

The output encoding

getCharsByCharCodes()

public SetaPDF_Core_Font::getCharsByCharCodes (
$charCodes [, $encoding = 'UTF-8' [, $asArray = true ]]
):

Converts char codes from the font specific encoding to another encoding.

Parameters
$charCodes

The char codes in the font specific encoding.

$encoding

The resulting encoding

$asArray
 

getDescent()

Returns the distance from baseline of lowest descender (Typographic descent).

getDictionary()

public SetaPDF_Core_Font::getDictionary (
void
):

Get the font dictionary.

getFontBBox()

Returns the font bounding box.

getFontBBoxVector()

public SetaPDF_Core_Font::getFontBBoxVector (
$name, $fontSize
):

Get a font bounding box vector.

Parameters
$name
 
$fontSize
 
Exceptions

Throws SetaPDF_Core_Exception

getFontDescriptor()

Get the font descriptor object.

getFontFamily()

Get the font family.

getFontName()

Get the font name.

getGlyphWidth()

public SetaPDF_Core_Font_Type1::getGlyphWidth (
$char [, $encoding = 'UTF-16BE' ]
):

Get the width of a glyph/character.

Parameters
$char
 
$encoding

The input encoding

See

getGlyphWidthByCharCode()

Get the width of a glpyh by its char code.

Parameters
$charCode
 

getGlyphsWidth()

public SetaPDF_Core_Font::getGlyphsWidth (
$chars [, $encoding = 'UTF-16BE' ]
):

Get the width of the glyphs/characters.

Parameters
$chars

The characters

$encoding

The input encoding

getIndirectObject()

public SetaPDF_Core_Font::getIndirectObject (
[ SetaPDF_Core_Document|null $document = null ]
):

Gets an indirect object for this font.

Parameters
$document : SetaPDF_Core_Document|null
 
Exceptions

Throws InvalidArgumentException

See

getInfo()

public SetaPDF_Core_Font::getInfo (
$name
):

Get information about the font.

Parameters
$name

The name of the font

getItalicAngle()

Returns the italic angle.

getMaxWidth()

Get the max glyph width.

getMissingWidth()

Get the missing glyph width.

getResourceType()

getType()

public SetaPDF_Core_Font::getType (
void
):

Get the Subtype entry of the font dictionary.

Exceptions

Throws SetaPDF_Core_Type_Exception

getUnderlinePosition()

Get the underline position.

getUnderlineThickness()

Get the underline thickness.

isBold()

public SetaPDF_Core_Font_Type1::isBold (
void
):

Checks if the font is bold.

isItalic()

Checks if the font is italic.

isMonospace()

Checks if the font is monospace.

recalculateFontBBox()

Re-calculate the font bounding box by analysing the metrics of all embedded glyphs.

Return Values

Format is [llx lly urx ury]. Returns false if the font isn't recalculatable

setUnderlinePosition()

public SetaPDF_Core_Font::setUnderlinePosition (
$position
): void

Sets the underline position for the current font.

Parameters
$position
 

setUnderlineThickness()

public SetaPDF_Core_Font::setUnderlineThickness (
$thickness
): void

Sets the underline thickness for the current font.

Parameters
$thickness
 

splitCharCodes()

public SetaPDF_Core_Font::splitCharCodes (
$charCodes
):

Split a string of char codes into single char codes.

Parameters
$charCodes