Parser
in package
Pdf font parser class
Tags
Table of Contents
Properties
- $cidFontObjectIndex : int|null
- CID (descendant) font object index
- $compression : bool
- Font compression flag
- $font : Type1|TrueType|null
- Font object
- $fontDescIndex : int|null
- Font descriptor index
- $fontFileIndex : int|null
- Font file index
- $fontIndex : int|null
- Font reference index
- $fontObjectIndex : int|null
- Font object index
- $objects : array<string|int, mixed>
- Font objects
- $toUnicodeIndex : int|null
- ToUnicode CMap stream object index
Methods
- __construct() : mixed
- Constructor
- getCidFontObjectIndex() : int|null
- Get the CID (descendant) font object index
- getFont() : AbstractFont|null
- Get the font object
- getFontDescIndex() : int|null
- Get the font descriptor index
- getFontFileIndex() : int|null
- Get the font file index
- getFontIndex() : int|null
- Get the font index
- getFontName() : string
- Method to get the font name.
- getFontObjectIndex() : int|null
- Get the font object index
- getFontReference() : string
- Method to get the font reference.
- getObjects() : array<string|int, mixed>
- Get the font objects
- getToUnicodeIndex() : int|null
- Get the ToUnicode CMap stream object index
- isCompressed() : bool
- Get whether or not the font objects are compressed
- isEmbeddable() : bool
- Method to get if the font is embeddable.
- loadFromStream() : void
- Load font from stream
- parse() : void
- Parse the font data and create the font objects
- setCidFontObjectIndex() : Parser
- Set the CID (descendant) font object index
- setCompression() : Parser
- Set the compression
- setFontDescIndex() : Parser
- Set the font descriptor index
- setFontFileIndex() : Parser
- Set the font file index
- setFontIndex() : Parser
- Set the font index
- setFontObjectIndex() : Parser
- Set the font object index
- setToUnicodeIndex() : Parser
- Set the ToUnicode CMap stream object index
- buildCidWidths() : string
- Build the /W (per-CID width) array for a CID font from GID-indexed glyph widths
- buildToUnicodeCMap() : string
- Build a /ToUnicode CMap stream mapping glyph IDs back to Unicode code units
Properties
$cidFontObjectIndex
CID (descendant) font object index
protected
int|null
$cidFontObjectIndex
= null
$compression
Font compression flag
protected
bool
$compression
= false
$font
Font object
protected
Type1|TrueType|null
$font
= null
$fontDescIndex
Font descriptor index
protected
int|null
$fontDescIndex
= null
$fontFileIndex
Font file index
protected
int|null
$fontFileIndex
= null
$fontIndex
Font reference index
protected
int|null
$fontIndex
= null
$fontObjectIndex
Font object index
protected
int|null
$fontObjectIndex
= null
$objects
Font objects
protected
array<string|int, mixed>
$objects
= []
$toUnicodeIndex
ToUnicode CMap stream object index
protected
int|null
$toUnicodeIndex
= null
Methods
__construct()
Constructor
public
__construct(string $fontFile[, bool $compression = false ]) : mixed
Instantiate a font parser object
Parameters
- $fontFile : string
- $compression : bool = false
Tags
getCidFontObjectIndex()
Get the CID (descendant) font object index
public
getCidFontObjectIndex() : int|null
Return values
int|nullgetFont()
Get the font object
public
getFont() : AbstractFont|null
Return values
AbstractFont|nullgetFontDescIndex()
Get the font descriptor index
public
getFontDescIndex() : int|null
Return values
int|nullgetFontFileIndex()
Get the font file index
public
getFontFileIndex() : int|null
Return values
int|nullgetFontIndex()
Get the font index
public
getFontIndex() : int|null
Return values
int|nullgetFontName()
Method to get the font name.
public
getFontName() : string
Return values
stringgetFontObjectIndex()
Get the font object index
public
getFontObjectIndex() : int|null
Return values
int|nullgetFontReference()
Method to get the font reference.
public
getFontReference() : string
Return values
stringgetObjects()
Get the font objects
public
getObjects() : array<string|int, mixed>
Return values
array<string|int, mixed>getToUnicodeIndex()
Get the ToUnicode CMap stream object index
public
getToUnicodeIndex() : int|null
Return values
int|nullisCompressed()
Get whether or not the font objects are compressed
public
isCompressed() : bool
Return values
boolisEmbeddable()
Method to get if the font is embeddable.
public
isEmbeddable() : bool
Return values
boolloadFromStream()
Load font from stream
public
static loadFromStream(string $stream) : void
Parameters
- $stream : string
parse()
Parse the font data and create the font objects
public
parse() : void
Tags
setCidFontObjectIndex()
Set the CID (descendant) font object index
public
setCidFontObjectIndex(int $index) : Parser
Parameters
- $index : int
Return values
ParsersetCompression()
Set the compression
public
setCompression(bool $compression) : Parser
Parameters
- $compression : bool
Return values
ParsersetFontDescIndex()
Set the font descriptor index
public
setFontDescIndex(int $index) : Parser
Parameters
- $index : int
Return values
ParsersetFontFileIndex()
Set the font file index
public
setFontFileIndex(int $index) : Parser
Parameters
- $index : int
Return values
ParsersetFontIndex()
Set the font index
public
setFontIndex(int $index) : Parser
Parameters
- $index : int
Return values
ParsersetFontObjectIndex()
Set the font object index
public
setFontObjectIndex(int $index) : Parser
Parameters
- $index : int
Return values
ParsersetToUnicodeIndex()
Set the ToUnicode CMap stream object index
public
setToUnicodeIndex(int $index) : Parser
Parameters
- $index : int
Return values
ParserbuildCidWidths()
Build the /W (per-CID width) array for a CID font from GID-indexed glyph widths
protected
buildCidWidths(TrueType $font) : string
hmtx-derived glyph widths are already contiguous from GID 0, so this emits a single 'c [w1 w2 ... wn]' run rather than detecting ranges.
Parameters
- $font : TrueType
Return values
stringbuildToUnicodeCMap()
Build a /ToUnicode CMap stream mapping glyph IDs back to Unicode code units
protected
buildToUnicodeCMap(TrueType $font) : string
Inverts the font's own codepoint => GID cmap. The inversion is lossy: several codepoints can share one GID (e.g. times.ttf maps both U+0020 and U+00A1 to GID 3), but a /ToUnicode CMap can only name one of them. The LOWEST codepoint wins, which keeps the ASCII/Latin-1 member of any such collision - so a space extracts as a space rather than as whatever exotic codepoint happened to be iterated last.
Parameters
- $font : TrueType