SetaPDF_Core_Font_Type0 Class for Type0 fonts

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

Class hierarchy

Implements

Summary

Static Properties

$_fonts

static protected array SetaPDF_Core_Font::$_fonts = array()

An array caching font objects


Properties

$_avgWidth

protected integer|float SetaPDF_Core_Font_Type0::$_avgWidth

The average width of glyphs in the font.

$_calcedFontBBox

The Calcilated font bounding box.

$_charCodeCache

protected array SetaPDF_Core_Font::$_charCodeCache = array()

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

$_dictionary

$_indirectObject

The indirect object of the font

$_info

protected array SetaPDF_Core_Font::$_info = array()

Array holding information about the font

$_splitCharCodesCache

Cache array for the splitCharCodes method.

$_streamParser

The TTF/OTF parser of the embedded font file.

$_substituteCharacter

The substitute character in a fonts specific encoding.

$_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 array SetaPDF_Core_Font_Type0::$_widths = array()

Cache for width values

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

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
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Type_IndirectReference_Exception


Methods

__construct()

_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).

_getDescendantFontDictionary()

Get the descandant font dictionary.

In PDF there's only a single descendant font.

_getEncodingTable()

Get the CMaps table for this font.

Exceptions

Throws SetaPDF_Core_Font_Exception

getAscent()

public SetaPDF_Core_Font_Type0::getAscent (
void
): float

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

getAvgWidth()

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

Get the average glyph width.

Parameters
$calculateIfUndefined : boolean
 

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_Type0::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
 

getDictionary()

Get the font dictionary.

getFontBBox()

public SetaPDF_Core_Font_Type0::getFontBBox (
[ boolean $recalc = false ]
): array

Returns the font bounding box.

Parameters
$recalc : boolean

Set to true, to re-calculate the font bounding box by analysing the metrics of all embedded glyphs.

getFontFamily()

public SetaPDF_Core_Font_Type0::getFontFamily (
void
): string|null

Get the font family.

getFontName()

public SetaPDF_Core_Font_Type0::getFontName (
void
): string

Get the font name.

getGlyphWidthByCharCode()

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

Get the width of a glpyh by its char code.

Parameters
$charCode : string
 

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_Type0::getItalicAngle (
void
): float

Returns the italic angle.

getMaxWidth()

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

Get the max glyph width.

getMissingWidth()

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

Get the missing glyph width.

getResourceType()

public SetaPDF_Core_Font::getResourceType (
void
): string

Get the resource type.

See

getStreamParser()

Get the TTF/OTF parser for the embedded font programm.

getType()

public SetaPDF_Core_Font::getType (
void
): mixed

Get the Subtype entry of the font dictionary.

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_Type0::isBold (
void
): boolean

Checks if the font is bold.

isItalic()

public SetaPDF_Core_Font_Type0::isItalic (
void
): boolean

Checks if the font is italic.

isMonospace()

public SetaPDF_Core_Font_Type0::isMonospace (
void
): boolean

Checks if the font is monospace.

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_Type0::splitCharCodes (
string $charCodes
): array

Split a string of char codes into single char codes.

Parameters
$charCodes : string