setasign\SetaPDF2\Core\Font

Type3 Class representing a Type3 font.

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

This class is only useable by existing MMType1 fonts.

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 Type3::$_avgWidth

The average width of glyphs in the font.

$_calculatedFontBBox

protected ?array Type3::$_calculatedFontBBox

$_charCodeCache

protected array Font::$_charCodeCache = array()

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

$_dictionary

The font dictionary

$_encodingTable

protected array Type3::$_encodingTable

The encoding table.

$_fontBBox

protected ?array Type3::$_fontBBox

The font bounding box

$_fontBBoxVector

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

$_fontDescriptor

The font descriptor object

$_fontMatrix

The font matrix

$_fontName

protected string Type3::$_fontName

The font name

$_indirectObject

The indirect object of the font

$_info

protected array Font::$_info = array()

Array holding information about the font

$_substituteCharacter

protected string Font::$_substituteCharacter

The substitute character in a fonts specific encoding.

$_toUnicodeTable

The to unicode table.

$_underlinePosition

protected null|int|float Font::$_underlinePosition

The relative underline positioning.

$_underlineThickness

protected null|int|float Font::$_underlineThickness

The underline thickness.

$_widths

protected array Type3::$_widths

Glyph widths

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

protected Type3::_getEncodingTable (
void
): array

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_getWidths()

protected Type3::_getWidths (
void
): void

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws Exception

getAscent()

public Type3::getAscent (
void
): float|false

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

Exceptions

Throws Exception

getAvgWidth()

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

Get the average glyph width.

Parameters
$calculateIfUndefined : bool
 
Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getBaseEncodingTable()

public Type3::getBaseEncodingTable (
void
): array

Get the base encoding of the font.

The base encoding for Type3 fonts is undefined but most readers/viewers use an ascii like table.

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

getDictionary()

Get the font dictionary.

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

Get the font descriptor object.

getFontFamily()

public Type3::getFontFamily (
void
): false

Get the font family.

Return Values

A type 3 font does not have a font family.

getFontMatrix()

Get the font matrix.

Exceptions

Throws \setasign\SetaPDF2\Core\Exception

getFontName()

public Type3::getFontName (
void
): string

Get the font name.

getGlyphWidth()

public Type3::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 Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See

getGlyphWidthByCharCode()

public Type3::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

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

Returns the italic angle.

getMaxWidth()

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

Get the max. glyph width.

Exceptions

Throws Exception

getMissingWidth()

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

Get the missing glyph width.

Exceptions

Throws Exception

getResourceType()

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 Type3::isBold (
void
): bool

Checks if the font is bold.

Exceptions

Throws Exception

isItalic()

public Type3::isItalic (
void
): bool

Checks if the font is italic.

isMonospace()

public Type3::isMonospace (
void
): bool

Checks if the font is monospace.

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

Split a string of char codes into single char codes.

Parameters
$charCodes : string