Stack extends Buffer
in package
Com\Tecnick\Pdf\Font\Stack
Tags
Table of Contents
Constants
- DEFAULT_SIZE = 10
- Default font size in points
Methods
- __construct() : string
- Initialize fonts buffer
- add() : string
- Add a new font to the fonts buffer
- addSubsetChar() : void
- Add a character to the subset list
- cloneFont() : TFontMetric
- Returns a clone of the specified font with new parameters.
- getCharBBox() : TBBox
- Returns the glyph bounding box of the specified character in the current font in user units.
- getCharWidth() : float
- Returns the width of the specified character
- getCurrentFont() : TFontMetric
- Returns the current font data array.
- getCurrentFontType() : string
- Returns the current font type (i.e.: Core, TrueType, TrueTypeUnicode, Type1).
- getEncDiffs() : array<int, string>
- Returns the fonts buffer
- getFont() : TFontData
- Get font by key
- getFonts() : array<string, TFontData>
- Returns the fonts buffer
- getOrdArrDims() : TTextDims
- Returns various dimensions of the string specified using an array of codepoints.
- getOrdArrWidth() : float
- Returns the lenght of the string specified using an array of codepoints.
- getOutCurrentFont() : string
- Returns the PDF code to use the current font.
- insert() : TFontMetric
- Insert a font into the stack
- isCharDefined() : bool
- Returns true if the specified unicode value is defined in the current font
- isCurrentByteFont() : bool
- Returns true if the current font type is Core, TrueType or Type1.
- isCurrentUnicodeFont() : bool
- Returns true if the current font type is TrueTypeUnicode or cidfont0.
- isSubsetMode() : bool
- Get the default subset mode
- isValidKey() : bool
- Returns true if the specified font key exist on buffer
- popLastFont() : TFontMetric
- Remove and return the last inserted font
- replaceChar() : int
- Replace a char if it is defined on the current font.
- replaceMissingChars() : array<int, int>
- Replace missing characters with selected substitutions
Constants
DEFAULT_SIZE
Default font size in points
public mixed DEFAULT_SIZE = 10
Methods
__construct()
Initialize fonts buffer
public __construct(float $kunit[,
bool $subset
= false
][,
bool $unicode
= true
][,
bool $pdfa
= false
]) : string
Parameters
- $kunit : float
-
Unit of measure conversion ratio.
- $subset : bool = false
-
If true embedd only a subset of the fonts (stores only the information related to the used characters); If false embedd full font; This option is valid only for TrueTypeUnicode fonts and it is disabled for PDF/A. If you want to enable users to modify the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only a subset. NOTE: This option is computational and memory intensive.
- $unicode : bool = true
-
True if we are in Unicode mode, False otherwhise.
- $pdfa : bool = false
-
True if we are in PDF/A mode.
Tags
Return values
string —Font key
add()
Add a new font to the fonts buffer
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 a subset of the font (stores only the information related to the used characters); If false embed full font; This option is valid only for TrueTypeUnicode fonts and it is disabled for PDF/A. If you want to enable users to modify the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only a subset. Set this to null to use the default value. NOTE: This option is computational and memory intensive.
Tags
Return values
string —Font key
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
cloneFont()
Returns a clone of the specified font with new parameters.
public cloneFont(int &$objnum[,
int|null $idx
= null
][,
string|null $style
= null
][,
int|null $size
= null
][,
float|null $spacing
= null
][,
float|null $stretching
= null
]) : TFontMetric
Parameters
- $objnum : int
-
Current PDF object number.
- $idx : int|null = null
-
Font index. Leave it null to use the current font.
- $style : string|null = null
-
Font style. Possible values are (case insensitive): regular (default) B: bold I: italic U: underline D: strikeout (linethrough) O: overline
- $size : int|null = null
-
Font size in points (set to null to inherit the last font size).
- $spacing : float|null = null
-
Extra spacing between characters.
- $stretching : float|null = null
-
Horizontal character stretching ratio.
Return values
TFontMetricgetCharBBox()
Returns the glyph bounding box of the specified character in the current font in user units.
public getCharBBox(int $ord)
: TBBox
Parameters
- $ord : int
-
Unicode character value.
Return values
TBBox —(xMin, yMin, xMax, yMax)
getCharWidth()
Returns the width of the specified character
public getCharWidth(int $ord)
: float
Parameters
- $ord : int
-
Unicode character value.
Return values
floatgetCurrentFont()
Returns the current font data array.
public getCurrentFont()
: TFontMetric
Return values
TFontMetricgetCurrentFontType()
Returns the current font type (i.e.: Core, TrueType, TrueTypeUnicode, Type1).
public getCurrentFontType()
: string
Return values
stringgetEncDiffs()
Returns the fonts buffer
public getEncDiffs()
: array<int,
string>
Return values
array<int, string>getFont()
Get font by key
public getFont(string $key)
: TFontData
Parameters
- $key : string
-
Font key
Tags
Return values
TFontData —Returns the fonts array.
getFonts()
Returns the fonts buffer
public getFonts()
: array<string,
TFontData>
Return values
array<string, TFontData>getOrdArrDims()
Returns various dimensions of the string specified using an array of codepoints.
public getOrdArrDims(array<int,
int> $uniarr)
: TTextDims
Parameters
- $uniarr : array<int, int>
-
Array of character codepoints.
Return values
TTextDimsgetOrdArrWidth()
Returns the lenght of the string specified using an array of codepoints.
public getOrdArrWidth(array<int,
int> $uniarr)
: float
Parameters
- $uniarr : array<int, int>
-
Array of character codepoints.
Return values
floatgetOutCurrentFont()
Returns the PDF code to use the current font.
public getOutCurrentFont()
: string
Return values
stringinsert()
Insert a font into the stack
public insert(int &$objnum,
string $font[,
string $style
= ''
][,
int|null $size
= null
][,
float|null $spacing
= null
][,
float|null $stretching
= null
][,
string $ifile
= ''
][,
bool|null $subset
= null
]) : TFontMetric
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, or comma separated list of font families 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
- $size : int|null = null
-
Font size in points (set to null to inherit the last font size).
- $spacing : float|null = null
-
Extra spacing between characters.
- $stretching : float|null = null
-
Horizontal character stretching ratio.
- $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 embedd only a subset of the font (stores only the information related to the used characters); If false embedd full font; This option is valid only for TrueTypeUnicode fonts and it is disabled for PDF/A. If you want to enable users to modify the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only a subset. Set this to null to use the default value. NOTE: This option is computational and memory intensive.
Tags
Return values
TFontMetric —Font data
isCharDefined()
Returns true if the specified unicode value is defined in the current font
public isCharDefined(int $ord)
: bool
Parameters
- $ord : int
-
Unicode character value to convert
Return values
boolisCurrentByteFont()
Returns true if the current font type is Core, TrueType or Type1.
public isCurrentByteFont()
: bool
Return values
boolisCurrentUnicodeFont()
Returns true if the current font type is TrueTypeUnicode or cidfont0.
public isCurrentUnicodeFont()
: bool
Return values
boolisSubsetMode()
Get the default subset mode
public isSubsetMode()
: bool
Return values
boolisValidKey()
Returns true if the specified font key exist on buffer
public isValidKey(string $key)
: bool
Parameters
- $key : string
-
Font key
Return values
boolpopLastFont()
Remove and return the last inserted font
public popLastFont()
: TFontMetric
Return values
TFontMetricreplaceChar()
Replace a char if it is defined on the current font.
public replaceChar(int $oldchar,
int $newchar)
: int
Parameters
- $oldchar : int
-
Integer code (unicode) of the character to replace.
- $newchar : int
-
Integer code (unicode) of the new character.
Return values
int —the replaced char or the old char in case the new char i not defined
replaceMissingChars()
Replace missing characters with selected substitutions
public replaceMissingChars(array<int,
int> $uniarr[,
array<int,
array<string|int, int>> $subs
= []
]) : array<int,
int>
Parameters
- $uniarr : array<int, int>
-
Array of character codepoints.
- $subs : array<int, array<string|int, int>> = []
-
Array of possible character substitutions. The key is the character to check (integer value), the value is an array of possible substitutes.
Return values
array<int, int> —Array of character codepoints.