SetaPDF_Core_Font_MMType1 Class representing a MMType1 font.

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

This class is only useable by existing MMType1 fonts.

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

$_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()

WARNING: This method is marked as deprecated!

Call SetaPDF_Core_Document::clearCache() with the type SetaPDF_Core_Document::CACHE_FONT instead.

public static SetaPDF_Core_Font::freeCache (): void

Release font instances by a document instance.

Parameters
$document : SetaPDF_Core_Document
 

freeFontCache()

WARNING: This method is marked as deprecated!

public static SetaPDF_Core_Font::freeFontCache (): void

Release font instances by a document instance.

Parameters
$document : SetaPDF_Core_Document
 
See

get()

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 : SetaPDF_Core_Type_IndirectObjectInterface|SetaPDF_Core_Type_Dictionary
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception

Throws SetaPDF_Core_Type_Exception


Methods

_ensureUnderlinePosition()

protected SetaPDF_Core_Font::_ensureUnderlinePosition (
void
): int|float

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()

protected SetaPDF_Core_Font::_ensureUnderlineThickness (
void
): float|int

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()

protected SetaPDF_Core_Font_Simple::_getEncodingTable (
void
): array

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.

Exceptions

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_Font_Exception

getAscent()

public SetaPDF_Core_Font_Type1::getAscent (
void
): float

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

Exceptions

Throws SetaPDF_Core_Font_Exception

getAvgWidth()

public SetaPDF_Core_Font_Type1::getAvgWidth (
[ boolean $calculateIfUndefined = false ]
): integer|float

Get the average glyph width.

Parameters
$calculateIfUndefined : boolean
 
Exceptions

Throws SetaPDF_Core_Font_Exception

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 (
string $charCode [, string $encoding = 'UTF-8' ]
): string

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

Parameters
$charCode : string

The char code in the font specific encoding.

$encoding : string

The resulting encoding

getCharCode()

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

Get the final character code of a single character.

Parameters
$char : string

The character

$encoding : string

The output encoding

getCharCodes()

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

Get the final character codes of a character string.

Parameters
$chars : string

The character string

$encoding : string

The output encoding

getCharsByCharCodes()

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

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

Parameters
$charCodes : string

The char codes in the font specific encoding.

$encoding : string

The resulting encoding

$asArray : bool
 

getDescent()

public SetaPDF_Core_Font_Type1::getDescent (
void
): float

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

Exceptions

Throws SetaPDF_Core_Font_Exception

getDictionary()

Get the font dictionary.

getFontBBox()

public SetaPDF_Core_Font_Type1::getFontBBox (
void
): array

Returns the font bounding box.

getFontBBoxVector()

public SetaPDF_Core_Font::getFontBBoxVector (
int $name, float $fontSize
): SetaPDF_Core_Geometry_Vector

Get a font bounding box vector.

Parameters
$name : int
 
$fontSize : float
 
Exceptions

Throws SetaPDF_Core_Exception

getFontDescriptor()

Get the font descriptor object.

getFontFamily()

public SetaPDF_Core_Font_Type1::getFontFamily (
void
): string

Get the font family.

Exceptions

Throws SetaPDF_Core_Font_Exception

getFontName()

public SetaPDF_Core_Font_Type1::getFontName (
void
): string

Get the font name.

getGlyphWidth()

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

Get the width of a glyph/character.

Parameters
$char : string
 
$encoding : string

The input encoding

Exceptions

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Type_Exception

See

getGlyphWidthByCharCode()

public SetaPDF_Core_Font_Type1::getGlyphWidthByCharCode (
string $charCode
): float|int

Get the width of a glpyh by its char code.

Parameters
$charCode : string
 
Exceptions

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Type_Exception

getGlyphsWidth()

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

Get the width of the glyphs/characters.

Parameters
$chars : string

The characters

$encoding : string

The input encoding

getIndirectObject()

getInfo()

public SetaPDF_Core_Font::getInfo (
string $name
): bool|string

Get information about the font.

Parameters
$name : string

The name of the font

getItalicAngle()

public SetaPDF_Core_Font_Type1::getItalicAngle (
void
): float

Returns the italic angle.

Exceptions

Throws SetaPDF_Core_Font_Exception

getMaxWidth()

public SetaPDF_Core_Font_Type1::getMaxWidth (
void
): integer|float

Get the max glyph width.

Exceptions

Throws SetaPDF_Core_Font_Exception

getMissingWidth()

public SetaPDF_Core_Font_Type1::getMissingWidth (
void
): integer|float

Get the missing glyph width.

Exceptions

Throws SetaPDF_Core_Font_Exception

getResourceType()

public SetaPDF_Core_Font::getResourceType (
void
): string

Get the resource type.

See

getType()

public SetaPDF_Core_Font::getType (
void
): string

Get the Subtype entry of the font dictionary.

Exceptions

Throws SetaPDF_Core_Type_Exception

getUnderlinePosition()

public SetaPDF_Core_Font::getUnderlinePosition (
void
): int|float

Get the underline position.

getUnderlineThickness()

public SetaPDF_Core_Font::getUnderlineThickness (
void
): int|float

Get the underline thickness.

isBold()

public SetaPDF_Core_Font_Type1::isBold (
void
): boolean

Checks if the font is bold.

Exceptions

Throws SetaPDF_Core_Font_Exception

isItalic()

public SetaPDF_Core_Font_Type1::isItalic (
void
): boolean

Checks if the font is italic.

Exceptions

Throws SetaPDF_Core_Font_Exception

isMonospace()

public SetaPDF_Core_Font_Type1::isMonospace (
void
): boolean

Checks if the font is monospace.

Exceptions

Throws SetaPDF_Core_Font_Exception

recalculateFontBBox()

public SetaPDF_Core_Font::recalculateFontBBox (
void
): false|array

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 (
int|float $position
): void

Sets the underline position for the current font.

Parameters
$position : int|float
 

setUnderlineThickness()

public SetaPDF_Core_Font::setUnderlineThickness (
int|float $thickness
): void

Sets the underline thickness for the current font.

Parameters
$thickness : int|float
 

splitCharCodes()

public SetaPDF_Core_Font::splitCharCodes (
string $charCodes
): array

Split a string of char codes into single char codes.

Parameters
$charCodes : string