Table of contents
Namespace: Com\Tecnick\Pdf\Font
abstract class Buffer
Source: src/Buffer.php:45
Types
TFileOptions
array{
allowedHosts?: array<string>,
maxRemoteSize?: int,
curlopts?: array<int, bool|int|string>,
defaultCurlOpts?: array<int, bool|int|string>,
fixedCurlOpts?: array<int, bool|int|string>
}
Methods
__construct()
Initialize fonts buffer
public __construct(
float $kunit,
bool $subset = false,
bool $unicode = true,
bool $pdfa = false,
File|null $fileHelper = null
)
Parameters:
$kunit(float): Unit of measure conversion ratio.$subset(bool): If true, embed only the characters used by the document. Valid only for TrueTypeUnicode fonts. Subsetting is computational and memory intensive.$unicode(bool): True if we are in Unicode mode, False otherwise.$pdfa(bool): True if we are in PDF/A mode, False otherwise.$fileHelper(File|null): Optional file helper for font loading.
Throws:
- Exception: if the unit ratio is not a positive number.
Source: src/Buffer.php:127
add()
Add a new font to the fonts buffer
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.
public add(
int &$objnum,
string $font,
string $style = '',
string $ifile = '',
?bool $subset = null
): string
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): If true, embed only the characters used by the document. Valid only for TrueTypeUnicode fonts. Set to null to use the default value for a new font, or to keep the mode of a font already in the buffer. Subsetting is computational and memory intensive.
Returns: string: Font key
Throws:
- Exception: in case of error
Source: src/Buffer.php:338
addFont()
Add a new font to the fonts buffer and report the style it provides.
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.
public addFont(
int &$objnum,
string $font,
string $style = '',
string $ifile = '',
?bool $subset = null
): array{key: string, style: string, fakestyle: string}
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): If true, embed only the characters used by the document. Set to null to use the default value for a new font, or to keep the mode of a font already in the buffer.
Returns: 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’).
Throws:
- Exception: in case of error
Source: src/Buffer.php:372
addSubsetChar()
Add a character to the subset list
public addSubsetChar(string $key, int $char): void
Parameters:
$key(string): The font key$char(int): The Unicode character value to add
Throws:
Source: src/Buffer.php:206
addUsedGid()
Record a glyph index used by the document and the codepoint it was encoded from.
The first codepoint mapped to a glyph is the one stored for it.
public addUsedGid(string $key, int $gid, int $ord): void
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
Throws:
- Exception: if the font is not loaded, or the glyph index is out of range
Source: src/Buffer.php:294
getEncDiffs()
Returns the encoding differences buffer
public getEncDiffs(): array<int,string>
Returns: array<int,string>
Source: src/Buffer.php:165
getFont()
Get font by key
public getFont(string $key): TFontData
Parameters:
$key(string): Font key
Returns: TFontData: Returns the fonts array.
Throws:
- Exception: in case of error
Source: src/Buffer.php:189
getFonts()
Returns the fonts buffer
public getFonts(): array<string,TFontData>
Returns: array<string,TFontData>
Source: src/Buffer.php:155
isSubsetMode()
Get the default subset mode
public isSubsetMode(): bool
Returns: bool
Source: src/Buffer.php:145
isValidKey()
Returns true if the specified font key exist on buffer
public isValidKey(string $key): bool
Parameters:
$key(string): Font key
Returns: bool
Source: src/Buffer.php:175