setasign\SetaPDF2\Core\Font\Type0

Subset Class that represents a PDF Type0 (Composite) font subset.

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

This class will embedded a subset of the original TrueType font programm with only glyphs, that were requested by calling the getCharCodes() method.

This font allows you to use several thousands of glyphs (there's a limit of 65000 glyphs).

Class hierarchy

Implements

Summary

Constants

STATE_FINISHED

State constant for a finished subset

STATE_NEW

State constant for a new created subset

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

$_ascent

The ascent value.

$_charCodes

protected array Subset::$_charCodes = array(...)

Mapping from UTF-16BE characters to glyph ids.

$_chars

protected array Subset::$_chars = array(...)

Mapping from glyph ids to UTF-16BE charcater codes.

$_cidToGlyphId

protected array Subset::$_cidToGlyphId = array(...)

Mapping array from character ids to glyph ids

$_descent

The descent value.

$_factor

The scaling factor from TrueType units to glyph coordinate system.

$_fontBBox

The font bounding box.

$_fontName

The font name.

$_indirectObject

$_isCidToGlyphMapIdentity

protected bool Subset::$_isCidToGlyphMapIdentity = true

Flag saying whether we can use Identity mapping or not.

$_state

The state of this subset

$_throwExceptionWhenMissingGlyphIsUsed

Flag saying whether an exception should be thrown if a character is not available or not.

$_widths

The widths of the used glyphs.

$_writeCidSet

protected bool Subset::$_writeCidSet = false

Flag saying whether to write the CIDSet entry or not.

$maxCharLimit

The char count limit.


Methods

__construct()

public Subset::__construct (
\SetaPDF_Core_Document $document,
\SetaPDF_Core_Font_TrueType_File|string|\SetaPDF_Core_Reader_Binary $fontFile,
bool $throwExceptionWhenMissingGlyphIsUsed = false,
bool $ignoreLicenseRestrictions = false
)

The constructor.

Parameters
$document : \SetaPDF_Core_Document
 
$fontFile : \SetaPDF_Core_Font_TrueType_File|string|\SetaPDF_Core_Reader_Binary
 
$throwExceptionWhenMissingGlyphIsUsed : bool

Whether an exception should be thrown if the registered character cannot be found or not.

$ignoreLicenseRestrictions : bool

Can be used to disable the font license check

Exceptions

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\Core\Font\TrueType\Subset\Exception

Throws \setasign\SetaPDF2\NotImplementedException

_checkState()

_createCidSet()

Create the CIDSet stream.

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

_createCidToGidMap()

Create the CIDtoGIDMap entry.

_getSubsetFile()

Gets the subset file instance.

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

_getToUnicode()

protected Subset::_getToUnicode (
void
): string

Returns the ToUnicode cmap.

_getWidthArray()

_registerChar()

protected Subset::_registerChar (
string $char,
string $charCode
): void

Registers a glyph that got registered in the font subsetter.

Parameters
$char : string
 
$charCode : string
 

cleanUp()

Release cycled references and memory.

createSubset()

public Subset::createSubset (
void
): void

Create the final subset file and embed it into the PDF document.

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getAscent()

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

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

getCharCodes()

public \setasign\SetaPDF2\Core\Font\TrueType\Subset::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

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getDescent()

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

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

getDocument()

getFontBBox()

getFontDescriptorFlags()

Get flags defining various characteristics of the font.

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

See
  • PDF 32000-1:2008 - 9.8.2 Font Descriptor Flags

getFontFile()

getGlyphWidth()

public \setasign\SetaPDF2\Core\Font\TrueType\Subset::getGlyphWidth (
string $char,
string $encoding = 'UTF-16BE'
): int

Get the glyph width of a single character.

Parameters
$char : string

The character

$encoding : string

The encoding of the character

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getGlyphWidthByCharCode()

Get the glyph width by a char code.

Parameters
$charCode : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getGlyphsWidth()

public \setasign\SetaPDF2\Core\Font\TrueType\Subset::getGlyphsWidth (
string $chars,
string $encoding = 'UTF-16BE'
): int

Get the glyphs width of a string.

Parameters
$chars : string

The string

$encoding : string

The encoding of the characters

Exceptions

Throws \setasign\SetaPDF2\Core\Font\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getIndirectObject()

Get the indirect object of this resource.

Parameters
$document : ?\SetaPDF_Core_Document
 

getRegisteredChars()

Get all registered characters (UTF-16BE encoded) indexed by their glyph ids.

getResourceType()

Get the resource type of an implementation.

getUnderlinePosition()

Get the underline position.

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

getUnderlineThickness()

Get the underline thickness.

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

setWriteCidSet()

public Subset::setWriteCidSet (
bool $writeCidSet = true
): void

Defines whether the CIDSet entry is created and written or not.

This was required for PDF/A-1 and are optional in PDF/A-2 and PDF/A-3.

Parameters
$writeCidSet : bool
 

splitCharCodes()

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

Split a string of char codes into single char codes.

Parameters
$charCodes : string