Documentation

TCPDF_FONTS
in package

Tags
class

TCPDF_FONTS Font methods for TCPDF library.

version
1.1.0
author

Nicola Asuni - info@tecnick.com

Table of Contents

Properties

$cache_uniord  : mixed
Static cache used for speed up uniord performances

Methods

_getfontpath()  : string
Return fonts path
_getTrueTypeFontSubset()  : string
Returns a subset of the TrueType font data without the unused glyphs.
_getTTFtableChecksum()  : int
Returs the checksum of a TTF table.
_putfontwidths()  : string
Outputs font widths
addTTFfont()  : string|false
Convert and add the selected TrueType or Type1 font to the fonts folder (that must be writeable).
arrUTF8ToUTF16BE()  : string
Converts array of UTF-8 characters to UTF16-BE string.<br> Based on: http://www.faqs.org/rfcs/rfc2781.html <pre> Encoding UTF-16:
getFontFullPath()  : string
Return font full path
getFontRefSize()  : float
Get a reference font size.
getUniord()  : int
Converts UTF-8 character to integer value.<br> Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br> Based on: http://www.faqs.org/rfcs/rfc3629.html <pre> Char. number range | UTF-8 octet sequence (hexadecimal) | (binary) --------------------+----------------------------------------------- 0000 0000-0000 007F | 0xxxxxxx 0000 0080-0000 07FF | 110xxxxx 10xxxxxx 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx ---------------------------------------------------------------------
UniArrSubString()  : string
Extract a slice of the $uniarr array and return it as string.
unichr()  : string
Returns the unicode caracter specified by the value
unichrASCII()  : string
Returns the unicode caracter specified by ASCII value
unichrUnicode()  : string
Returns the unicode caracter specified by UTF-8 value
uniord()  : int
Converts UTF-8 character to integer value.<br> Uses the getUniord() method if the value is not cached.
updateCIDtoGIDmap()  : string
Update the CIDToGIDMap string with a new value.
UTF8ArrayToUniArray()  : array<string|int, mixed>
Convert an array of UTF8 values to array of unicode characters
UTF8ArrSubString()  : string
Extract a slice of the $strarr array and return it as string.
UTF8ArrToLatin1()  : string
Converts UTF-8 characters array to Latin1 string<br>
UTF8ArrToLatin1Arr()  : array<string|int, mixed>
Converts UTF-8 characters array to array of Latin1 characters array<br>
utf8Bidi()  : array<string|int, mixed>
Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
utf8StrArrRev()  : string
Reverse the RLT substrings array using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
UTF8StringToArray()  : array<string|int, mixed>
Converts UTF-8 strings to codepoints array.<br> Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br>
utf8StrRev()  : string
Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).
UTF8ToLatin1()  : string
Converts UTF-8 strings to Latin1 when using the standard 14 core fonts.<br>
UTF8ToUTF16BE()  : string
Converts UTF-8 strings to UTF16-BE.<br>

Properties

$cache_uniord

Static cache used for speed up uniord performances

protected static mixed $cache_uniord = array()
Tags
protected

Methods

_getfontpath()

Return fonts path

public static _getfontpath() : string
Tags
public

static

Return values
string

_getTrueTypeFontSubset()

Returns a subset of the TrueType font data without the unused glyphs.

public static _getTrueTypeFontSubset(string $font, array<string|int, mixed> $subsetchars) : string
Parameters
$font : string

TrueType font data.

$subsetchars : array<string|int, mixed>

Array of used characters (the glyphs to keep).

Tags
author

Nicola Asuni

since
5.2.000

(2010-06-02)

public

static

Return values
string —

A subset of TrueType font data without the unused glyphs.

_getTTFtableChecksum()

Returs the checksum of a TTF table.

public static _getTTFtableChecksum(string $table, int $length) : int
Parameters
$table : string

table to check

$length : int

length of table in bytes

Tags
author

Nicola Asuni

since
5.2.000

(2010-06-02)

public

static

Return values
int —

checksum

_putfontwidths()

Outputs font widths

public static _putfontwidths(array<string|int, mixed> $font[, int $cidoffset = 0 ]) : string
Parameters
$font : array<string|int, mixed>

font data

$cidoffset : int = 0

offset for CID values

Tags
author

Nicola Asuni

since
4.4.000

(2008-12-07)

public

static

Return values
string —

PDF command string for font widths

addTTFfont()

Convert and add the selected TrueType or Type1 font to the fonts folder (that must be writeable).

public static addTTFfont(string $fontfile[, string $fonttype = '' ][, string $enc = '' ][, int $flags = 32 ][, string $outpath = '' ][, int $platid = 3 ][, int $encid = 1 ][, bool $addcbbox = false ][, bool $link = false ]) : string|false
Parameters
$fontfile : string

Font file (full path).

$fonttype : string = ''

Font type. Leave empty for autodetect mode. Valid values are: TrueTypeUnicode, TrueType, Type1, CID0JP = CID-0 Japanese, CID0KR = CID-0 Korean, CID0CS = CID-0 Chinese Simplified, CID0CT = CID-0 Chinese Traditional.

$enc : string = ''

Name of the encoding table to use. Leave empty for default mode. Omit this parameter for TrueType Unicode and symbolic fonts like Symbol or ZapfDingBats.

$flags : int = 32

Unsigned 32-bit integer containing flags specifying various characteristics of the font (PDF32000:2008 - 9.8.2 Font Descriptor Flags): +1 for fixed font; +4 for symbol or +32 for non-symbol; +64 for italic. Fixed and Italic mode are generally autodetected so you have to set it to 32 = non-symbolic font (default) or 4 = symbolic font.

$outpath : string = ''

Output path for generated font files (must be writeable by the web server). Leave empty for default font folder.

$platid : int = 3

Platform ID for CMAP table to extract (when building a Unicode font for Windows this value should be 3, for Macintosh should be 1).

$encid : int = 1

Encoding ID for CMAP table to extract (when building a Unicode font for Windows this value should be 1, for Macintosh should be 0). When Platform ID is 3, legal values for Encoding ID are: 0=Symbol, 1=Unicode, 2=ShiftJIS, 3=PRC, 4=Big5, 5=Wansung, 6=Johab, 7=Reserved, 8=Reserved, 9=Reserved, 10=UCS-4.

$addcbbox : bool = false

If true includes the character bounding box information on the php font file.

$link : bool = false

If true link to system font instead of copying the font data (not transportable) - Note: do not work with Type1 fonts.

Tags
author

Nicola Asuni

since
5.9.123

(2010-09-30)

public

static

Return values
string|false —

TCPDF font name or boolean false in case of error.

arrUTF8ToUTF16BE()

Converts array of UTF-8 characters to UTF16-BE string.<br> Based on: http://www.faqs.org/rfcs/rfc2781.html <pre> Encoding UTF-16:

public static arrUTF8ToUTF16BE(array<string|int, mixed> $unicode[, bool $setbom = false ]) : string

Encoding of a single character from an ISO 10646 character value to UTF-16 proceeds as follows. Let U be the character number, no greater than 0x10FFFF.

  1. If U < 0x10000, encode U as a 16-bit unsigned integer and terminate.

  2. Let U' = U - 0x10000. Because U is less than or equal to 0x10FFFF, U' must be less than or equal to 0xFFFFF. That is, U' can be represented in 20 bits.

  3. Initialize two 16-bit unsigned integers, W1 and W2, to 0xD800 and 0xDC00, respectively. These integers each have 10 bits free to encode the character value, for a total of 20 bits.

  4. Assign the 10 high-order bits of the 20-bit U' to the 10 low-order bits of W1 and the 10 low-order bits of U' to the 10 low-order bits of W2. Terminate.

Graphically, steps 2 through 4 look like: U' = yyyyyyyyyyxxxxxxxxxx W1 = 110110yyyyyyyyyy W2 = 110111xxxxxxxxxx

Parameters
$unicode : array<string|int, mixed>

array containing UTF-8 unicode values

$setbom : bool = false

if true set the Byte Order Mark (BOM = 0xFEFF)

Tags
protected
author

Nicola Asuni

since
2.1.000

(2008-01-08)

public

static

Return values
string

getFontFullPath()

Return font full path

public static getFontFullPath(string $file[, string $fontdir = false ]) : string
Parameters
$file : string

Font file name.

$fontdir : string = false

Font directory (set to false fto search on default directories)

Tags
author

Nicola Asuni

since
6.0.025
public

static

Return values
string —

Font full path or empty string

getFontRefSize()

Get a reference font size.

public static getFontRefSize(string $size[, float $refsize = 12 ]) : float
Parameters
$size : string

String containing font size value.

$refsize : float = 12

Reference font size in points.

Tags
public

static

Return values
float —

value in points

getUniord()

Converts UTF-8 character to integer value.<br> Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br> Based on: http://www.faqs.org/rfcs/rfc3629.html <pre> Char. number range | UTF-8 octet sequence (hexadecimal) | (binary) --------------------+----------------------------------------------- 0000 0000-0000 007F | 0xxxxxxx 0000 0080-0000 07FF | 110xxxxx 10xxxxxx 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx ---------------------------------------------------------------------

public static getUniord(string $uch) : int

ABFN notation:

UTF8-octets = *( UTF8-char ) UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4 UTF8-1 = %x00-7F UTF8-2 = %xC2-DF UTF8-tail

UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail ) UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / %xF4 %x80-8F 2( UTF8-tail ) UTF8-tail = %x80-BF

Parameters
$uch : string

character string to process.

Tags
author

Nicola Asuni

public

static

Return values
int —

Unicode value

UniArrSubString()

Extract a slice of the $uniarr array and return it as string.

public static UniArrSubString(array<string|int, string> $uniarr[, int $start = '' ][, int $end = '' ]) : string
Parameters
$uniarr : array<string|int, string>

The input array of characters.

$start : int = ''

the starting element of $strarr.

$end : int = ''

first element that will not be returned.

Tags
since
4.5.037

(2009-04-07)

public

static

Return values
string —

Return part of a string

unichr()

Returns the unicode caracter specified by the value

public static unichr(int $c[, bool $unicode = true ]) : string
Parameters
$c : int

UTF-8 value

$unicode : bool = true

True if we are in unicode mode, false otherwise.

Tags
since
2.3.000

(2008-03-05)

public

static

Return values
string —

Returns the specified character.

unichrASCII()

Returns the unicode caracter specified by ASCII value

public static unichrASCII(int $c) : string
Parameters
$c : int

UTF-8 value

Tags
public

static

Return values
string —

Returns the specified character.

unichrUnicode()

Returns the unicode caracter specified by UTF-8 value

public static unichrUnicode(int $c) : string
Parameters
$c : int

UTF-8 value

Tags
public

static

Return values
string —

Returns the specified character.

uniord()

Converts UTF-8 character to integer value.<br> Uses the getUniord() method if the value is not cached.

public static uniord(string $uch) : int
Parameters
$uch : string

character string to process.

Tags
public

static

Return values
int —

Unicode value

updateCIDtoGIDmap()

Update the CIDToGIDMap string with a new value.

public static updateCIDtoGIDmap(string $map, int $cid, int $gid) : string
Parameters
$map : string

CIDToGIDMap.

$cid : int

CID value.

$gid : int

GID value.

Tags
author

Nicola Asuni

since
5.9.123

(2011-09-29)

public

static

Return values
string —

CIDToGIDMap.

UTF8ArrayToUniArray()

Convert an array of UTF8 values to array of unicode characters

public static UTF8ArrayToUniArray(array<string|int, mixed> $ta[, bool $isunicode = true ]) : array<string|int, mixed>
Parameters
$ta : array<string|int, mixed>

The input array of UTF8 values.

$isunicode : bool = true

True for Unicode mode, false otherwise.

Tags
since
4.5.037

(2009-04-07)

public

static

Return values
array<string|int, mixed> —

Return array of unicode characters

UTF8ArrSubString()

Extract a slice of the $strarr array and return it as string.

public static UTF8ArrSubString(array<string|int, string> $strarr[, int $start = '' ][, int $end = '' ][, bool $unicode = true ]) : string
Parameters
$strarr : array<string|int, string>

The input array of characters.

$start : int = ''

the starting element of $strarr.

$end : int = ''

first element that will not be returned.

$unicode : bool = true

True if we are in unicode mode, false otherwise.

Tags
public

static

Return values
string —

Return part of a string

UTF8ArrToLatin1()

Converts UTF-8 characters array to Latin1 string<br>

public static UTF8ArrToLatin1(array<string|int, mixed> $unicode) : string
Parameters
$unicode : array<string|int, mixed>

array containing UTF-8 unicode values

Tags
author

Nicola Asuni

since
4.8.023

(2010-01-15)

public

static

Return values
string

UTF8ArrToLatin1Arr()

Converts UTF-8 characters array to array of Latin1 characters array<br>

public static UTF8ArrToLatin1Arr(array<string|int, mixed> $unicode) : array<string|int, mixed>
Parameters
$unicode : array<string|int, mixed>

array containing UTF-8 unicode values

Tags
author

Nicola Asuni

since
4.8.023

(2010-01-15)

public

static

Return values
array<string|int, mixed>

utf8Bidi()

Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).

public static utf8Bidi(array<string|int, mixed> $ta, string $str, bool $forcertl, bool $isunicode, array<string|int, mixed> &$currentfont) : array<string|int, mixed>
Parameters
$ta : array<string|int, mixed>

array of characters composing the string.

$str : string

string to process

$forcertl : bool

if 'R' forces RTL, if 'L' forces LTR

$isunicode : bool

True if the document is in Unicode mode, false otherwise.

$currentfont : array<string|int, mixed>

Reference to current font array.

Tags
author

Nicola Asuni

since
2.4.000

(2008-03-06)

public

static

Return values
array<string|int, mixed> —

of unicode chars

utf8StrArrRev()

Reverse the RLT substrings array using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).

public static utf8StrArrRev(array<string|int, mixed> $arr, string $str, bool $setbom, bool $forcertl, bool $isunicode, array<string|int, mixed> &$currentfont) : string
Parameters
$arr : array<string|int, mixed>

array of unicode values.

$str : string

string to manipulate (or empty value).

$setbom : bool

if true set the Byte Order Mark (BOM = 0xFEFF)

$forcertl : bool

if true forces RTL text direction

$isunicode : bool

True if the document is in Unicode mode, false otherwise.

$currentfont : array<string|int, mixed>

Reference to current font array.

Tags
author

Nicola Asuni

since
4.9.000

(2010-03-27)

public

static

Return values
string

UTF8StringToArray()

Converts UTF-8 strings to codepoints array.<br> Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br>

public static UTF8StringToArray(string $str, bool $isunicode, array<string|int, mixed> &$currentfont) : array<string|int, mixed>
Parameters
$str : string

string to process.

$isunicode : bool

True when the documetn is in Unicode mode, false otherwise.

$currentfont : array<string|int, mixed>

Reference to current font array.

Tags
author

Nicola Asuni

public

static

Return values
array<string|int, mixed> —

containing codepoints (UTF-8 characters values)

utf8StrRev()

Reverse the RLT substrings using the Bidirectional Algorithm (http://unicode.org/reports/tr9/).

public static utf8StrRev(string $str, bool $setbom, bool $forcertl, bool $isunicode, array<string|int, mixed> &$currentfont) : string
Parameters
$str : string

string to manipulate.

$setbom : bool

if true set the Byte Order Mark (BOM = 0xFEFF)

$forcertl : bool

if true forces RTL text direction

$isunicode : bool

True if the document is in Unicode mode, false otherwise.

$currentfont : array<string|int, mixed>

Reference to current font array.

Tags
author

Nicola Asuni

since
2.1.000

(2008-01-08)

public

static

Return values
string

UTF8ToLatin1()

Converts UTF-8 strings to Latin1 when using the standard 14 core fonts.<br>

public static UTF8ToLatin1(string $str, bool $isunicode, array<string|int, mixed> &$currentfont) : string
Parameters
$str : string

string to process.

$isunicode : bool

True when the documetn is in Unicode mode, false otherwise.

$currentfont : array<string|int, mixed>

Reference to current font array.

Tags
since
3.2.000

(2008-06-23)

public

static

Return values
string

UTF8ToUTF16BE()

Converts UTF-8 strings to UTF16-BE.<br>

public static UTF8ToUTF16BE(string $str, bool $setbom, bool $isunicode, array<string|int, mixed> &$currentfont) : string
Parameters
$str : string

string to process.

$setbom : bool

if true set the Byte Order Mark (BOM = 0xFEFF)

$isunicode : bool

True when the documetn is in Unicode mode, false otherwise.

$currentfont : array<string|int, mixed>

Reference to current font array.

Tags
author

Nicola Asuni

since
1.53.0.TC005

(2005-01-05)

public

static

Return values
string

        
On this page

Search results