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

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

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

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

$_ascent

The ascent value.

$_charCodes

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

Mapping from UTF-16BE characters to glyph ids.

$_chars

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

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

$_cidToGlyphId

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

Mapping array from character ids to glyph ids

$_descent

The descent value.

$_dictionary

$_document

$_factor

The scaling factor from TrueType units to glyph coordinate system.

$_fontBBox

The font bounding box.

$_fontFile

$_fontName

The font name.

$_indirectObject

The indirect object for the PDF font object.

$_isCidToGlyphMapIdentity

Flag saying whether we can use Identity mapping or not.

$_throwExceptionWhenMissingGlyphIsUsed

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

$_widths

protected int[] SetaPDF_Core_Font_TrueType_Subset::$_widths = array()

The widths of the used glyphs.

$_writeCidSet

Flag saying whether to write the CIDSet entry or not.

$maxCharLimit

The char count limit.


Methods

__construct()

public SetaPDF_Core_Font_Type0_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 SetaPDF_Core_Exception

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Core_Font_TrueType_Subset_Exception

Throws SetaPDF_Exception_NotImplemented

_createCidSet()

Create the CIDSet stream.

Exceptions

Throws SetaPDF_Core_Font_Exception

_createCidToGidMap()

_createSubset()

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

Exceptions

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

_getSubsetFile()

_getToUnicode()

protected SetaPDF_Core_Font_Type0_Subset::_getToUnicode (
void
): string

Returns the ToUnicode cmap.

_getWidthArray()

_registerChar()

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

getAscent()

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

Exceptions

Throws SetaPDF_Exception_NotImplemented

getCharCodes()

public SetaPDF_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 SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

getDescent()

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

Exceptions

Throws SetaPDF_Exception_NotImplemented

getDocument()

Get the document instance.

getFontBBox()

Get the font bounding box array.

Exceptions

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

getFontDescriptorFlags()

Get flags defining various characteristics of the font.

Exceptions

Throws SetaPDF_Exception_NotImplemented

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

getFontFile()

Get the source true type file.

getFontName()

Get the font name.

Exceptions

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

getGlyphWidth()

public SetaPDF_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 SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

getGlyphWidthByCharCode()

Get the glyph width by a char code.

Parameters
$charCode : string
 
Exceptions

Throws SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

getGlyphsWidth()

public SetaPDF_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 SetaPDF_Core_Font_Exception

Throws SetaPDF_Exception_NotImplemented

getIndirectObject()

Get the indirect object of this resource.

Parameters
$document : SetaPDF_Core_Document|null
 

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 SetaPDF_Exception_NotImplemented

getUnderlineThickness()

Get the underline thickness.

Exceptions

Throws SetaPDF_Exception_NotImplemented

setWriteCidSet()

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

Split a string of char codes into single char codes.

Parameters
$charCodes : string