setasign\SetaPDF2\Core\Font

Type0 Class for Type0 fonts

File: /SetaPDF v2/Core/Font/Type0.php
Old class name (alias): \SetaPDF_Core_Font_Type0

Class hierarchy

Implements

Summary

Constants

INFO_COPYRIGHT

public const string Font::INFO_COPYRIGHT = 'copyright'

Info constant

INFO_CREATION_DATE

public const string Font::INFO_CREATION_DATE = 'creationDate'

Info constant

INFO_UNIQUE_ID

public const string Font::INFO_UNIQUE_ID = 'uniqueId'

Info constant

INFO_VERSION

public const string Font::INFO_VERSION = 'version'

Info constant

TYPE_COLOR_SPACE

Type constant

TYPE_EXT_G_STATE

Type constant

TYPE_FONT

Type constant

TYPE_PATTERN

Type constant

TYPE_PROC_SET

Type constant

TYPE_PROPERTIES

Type constant

TYPE_SHADING

Type constant

TYPE_X_OBJECT

Type constant


Properties

$_avgWidth

protected int|float Type0::$_avgWidth

The average width of glyphs in the font.

$_calculatedFontBBox

protected ?array Type0::$_calculatedFontBBox

$_charCodeCache

protected array Font::$_charCodeCache = array()

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

$_dictionary

The font dictionary

$_encodingTable

$_fontBBox

protected ?array Type0::$_fontBBox

The font bounding box

$_fontBBoxVector

protected array<string, \SetaPDF_Core_Geometry_Point> Font::$_fontBBoxVector = array()

$_indirectObject

The indirect object of the font

$_info

protected array Font::$_info = array()

Array holding information about the font

$_splitCharCodesCache

protected array Type0::$_splitCharCodesCache = array()

Cache array for the splitCharCodes method.

$_streamParser

The TTF/OTF parser of the embedded font file.

$_substituteCharacter

protected string Font::$_substituteCharacter

The substitute character in a fonts specific encoding.

$_underlinePosition

protected null|int|float Font::$_underlinePosition

The relative underline positioning.

$_underlineThickness

protected null|int|float Font::$_underlineThickness

The underline thickness.

$_widths

protected array Type0::$_widths = array()

Cache for width values

$_widthsByCharCode

protected array Font::$_widthsByCharCode

Widths by char codes


Static Methods

freeCache()

WARNING: This method is marked as deprecated!

Call \setasign\SetaPDF2\Core\Document::clearCache() with the type \setasign\SetaPDF2\Core\Document::CACHE_FONT instead.

public static 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 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 \setasign\SetaPDF2\NotImplementedException

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception


Methods

__construct()

_ensureUnderlinePosition()

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

_getEncodingTable()

getAscent()

public Type0::getAscent (
void
): float

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

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getAvgWidth()

public Type0::getAvgWidth (
bool $calculateIfUndefined = false
): int|float

Get the average glyph width.

Parameters
$calculateIfUndefined : bool
 
Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getCharByCharCode()

public 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 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 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 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
 
Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getDescendantFont()

getDictionary()

Get the font dictionary.

getFontBBox()

public Type0::getFontBBox (
void
): array

Returns the font bounding box.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getFontBBoxVector()

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

Get a font bounding box vector.

Parameters
$name : int
 
$fontSize : float
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception

getFontDescriptor()

getFontFamily()

public Type0::getFontFamily (
void
): false|string

Get the font family.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getFontName()

public Type0::getFontName (
void
): string

Get the font name.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getGlyphWidthByCharCode()

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

Get the width of a glpyh by its char code.

Parameters
$charCode : string
 
Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getGlyphsWidth()

public 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 Font::getInfo (
string $name
): bool|string

Get information about the font.

Parameters
$name : string

The name of the font

getItalicAngle()

public Type0::getItalicAngle (
void
): float

Returns the italic angle.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getMaxWidth()

public Type0::getMaxWidth (
void
): int|float

Get the max glyph width.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getMissingWidth()

public Type0::getMissingWidth (
void
): int|float

Get the missing glyph width.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getResourceType()

getStreamParser()

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

Exceptions

Throws \setasign\SetaPDF2\Core\Exception

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getType()

public Font::getType (
void
): string

Get the Subtype entry of the font dictionary.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getUnderlinePosition()

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

Get the underline position.

getUnderlineThickness()

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

Get the underline thickness.

isBold()

public Type0::isBold (
void
): bool

Checks if the font is bold.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

isItalic()

public Type0::isItalic (
void
): bool

Checks if the font is italic.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

isMonospace()

public Type0::isMonospace (
void
): bool

Checks if the font is monospace.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

recalculateFontBBox()

setUnderlinePosition()

public Font::setUnderlinePosition (
int|float $position
): void

Sets the underline position for the current font.

Parameters
$position : int|float
 

setUnderlineThickness()

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

Sets the underline thickness for the current font.

Parameters
$thickness : int|float
 

splitCharCodes()

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

Split a string of char codes into single char codes.

Parameters
$charCodes : string
 
Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\NotImplementedException