Table of contents
Namespace: Com\Tecnick\Pdf\Font
Abstract: Yes
File: Buffer.php line 45
Tags
- since: 2011-05-23
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2011-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-pdf-font
- phpstan-type: TFileOptions array{ allowedHosts?: array, maxRemoteSize?: int, curlopts?: array<int, bool|int|string>, defaultCurlOpts?: array<int, bool|int|string>, fixedCurlOpts?: array<int, bool|int|string> }
- phpstan-import-type: TFontData from Load
Methods
__construct()
File: Buffer.php line 127
public __construct(float $kunit[, bool $subset = false ][, bool $unicode = true ][, bool $pdfa = false ][, File|null $fileHelper = null ]) : mixed
Parameters
- $kunit : float: Unit of measure conversion ratio.
- $subset : bool = false: If true, embed only the characters used by the document. Valid only for TrueTypeUnicode fonts. Subsetting is computational and memory intensive.
- $unicode : bool = true: True if we are in Unicode mode, False otherwise.
- $pdfa : bool = false: True if we are in PDF/A mode, False otherwise.
- $fileHelper : File|null = null: Optional file helper for font loading.
Tags
- throws: Exception if the unit ratio is not a positive number.
add()
File: Buffer.php line 337
public add(int &$objnum, string $font[, string $style = '' ][, string $ifile = '' ][, bool|null $subset = null ]) : string
The definition file (and the font file itself when embedding) must be present either in the current directory or in the one indicated by K_PATH_FONTS if the constant is defined.
Parameters
- $objnum : int: Current PDF object number
- $font : string: Font family. If it is a standard family name, it will override the corresponding font.
- $style : string = ‘’: Font style. Possible values are (case-insensitive): regular (default) B: bold I: italic U: underline D: strikeout (linethrough) O: overline
- $ifile : string = ‘’: The font definition file (or empty for autodetect). By default, the name is built from the family and style, in lower case with no spaces.
- $subset : bool|null = null: If true, embed only the characters used by the document. Valid only for TrueTypeUnicode fonts. Set to null to use the default value. Subsetting is computational and memory intensive.
Tags
- throws: Exception in case of error
Return values
string —
Font key
addFont()
File: Buffer.php line 369
public addFont(int &$objnum, string $font[, string $style = '' ][, string $ifile = '' ][, bool|null $subset = null ]) : array{key: string, style: string, fakestyle: string}
A family that ships no definition file for the requested variation is loaded from the file of its base family and buffered under the base key, so the same glyph program is neither held nor embedded twice. The variation is then reported as synthetic and is painted by the caller when it draws the text.
Parameters
- $objnum : int: Current PDF object number
- $font : string: Font family.
- $style : string = ‘’: Font style (see add()).
- $ifile : string = ‘’: The font definition file (or empty for autodetect).
- $subset : bool|null = null: If true, embed only the characters used by the document.
Tags
- throws: Exception in case of error
Return values
array{key: string, style: string, fakestyle: string} —
Font key, requested style, and the part of it the font does not provide (’’, ‘B’, ‘I’ or ‘BI’).
addSubsetChar()
File: Buffer.php line 206
public addSubsetChar(string $key, int $char) : void
Parameters
- $key : string: The font key
- $char : int: The Unicode character value to add
Tags
- throws: Exception
addUsedGid()
File: Buffer.php line 294
public addUsedGid(string $key, int $gid, int $ord) : void
The first codepoint mapped to a glyph is the one stored for it.
Parameters
- $key : string: The font key
- $gid : int: The glyph index, in the 0..65535 range
- $ord : int: The Unicode codepoint the glyph was selected for
Tags
- throws: Exception if the font is not loaded, or the glyph index is out of range
getEncDiffs()
File: Buffer.php line 165
public getEncDiffs() : array<int, string>
Return values
array<int, string>
getFont()
File: Buffer.php line 189
public getFont(string $key) : TFontData
Parameters
- $key : string: Font key
Tags
- throws: Exception in case of error
Return values
TFontData —
Returns the fonts array.
getFonts()
File: Buffer.php line 155
public getFonts() : array<string, TFontData>
Return values
array<string, TFontData>
isSubsetMode()
File: Buffer.php line 145
public isSubsetMode() : bool
Return values
bool
isValidKey()
File: Buffer.php line 175
public isValidKey(string $key) : bool
Parameters
- $key : string: Font key
Return values
bool