classes-TCPDF-FONTS

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Tags
class

TCPDF_FONTS Font methods for TCPDF library.

version
1.1.0
author

Nicola Asuni - info@tecnick.com

Table of Contents

$cache_uniord  : mixed
Static cache used for speed up uniord performances
_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()  : PDF
Outputs font widths
addTTFfont()  : (string)
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()  : Return
Extract a slice of the $uniarr array and return it as string.
unichr()  : Returns
Returns the unicode caracter specified by the value
unichrASCII()  : Returns
Returns the unicode caracter specified by ASCII value
unichrUnicode()  : Returns
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()  : Return
Convert an array of UTF8 values to array of unicode characters
UTF8ArrSubString()  : Return
Extract a slice of the $strarr array and return it as string.
UTF8ArrToLatin1()  : array<string|int, mixed>
Converts UTF-8 characters array to array of 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( $font,  $subsetchars) : (string)
Parameters
$font :

(string) TrueType font data.

$subsetchars :

(array) 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( $table,  $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( $font,  $cidoffset) : PDF
Parameters
$font :

(array) font data

$cidoffset :

(int) offset for CID values

Tags
author

Nicola Asuni

since
4.4.000

(2008-12-07)

public

static

Return values
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( $fontfile[,  $fonttype = '' ][,  $enc = '' ][,  $flags = 32 ][,  $outpath = '' ][,  $platid = 3 ][,  $encid = 1 ][,  $addcbbox = false ][,  $link = false ]) : (string)
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 : = 32

(int) 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 : = 3

(int) 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 : = 1

(int) 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 : = false

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

$link : = false

(boolean) 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)

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( $unicode[,  $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) array containing UTF-8 unicode values

$setbom : = false

(boolean) 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( $file[,  $fontdir = false ]) : string
Parameters
$file :

(string) Font file name.

$fontdir : = false

(string) 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( $size[,  $refsize = 12 ]) : float
Parameters
$size :

(string) String containing font size value.

$refsize : = 12

(float) 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( $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( $uniarr[,  $start = '' ][,  $end = '' ]) : Return
Parameters
$uniarr :

(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
Return

part of a string

unichr()

Returns the unicode caracter specified by the value

public static unichr( $c[,  $unicode = true ]) : Returns
Parameters
$c :

(int) UTF-8 value

$unicode : = true

(boolean) True if we are in unicode mode, false otherwise.

Tags
since
2.3.000

(2008-03-05)

public

static

Return values
Returns

the specified character.

unichrASCII()

Returns the unicode caracter specified by ASCII value

public static unichrASCII( $c) : Returns
Parameters
$c :

(int) UTF-8 value

Tags
public

static

Return values
Returns

the specified character.

unichrUnicode()

Returns the unicode caracter specified by UTF-8 value

public static unichrUnicode( $c) : Returns
Parameters
$c :

(int) UTF-8 value

Tags
public

static

Return values
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( $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( $map,  $cid,  $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( $ta[,  $isunicode = true ]) : Return
Parameters
$ta :

(array) The input array of UTF8 values.

$isunicode : = true

(boolean) True for Unicode mode, false otherwise.

Tags
since
4.5.037

(2009-04-07)

public

static

Return values
Return

array of unicode characters

UTF8ArrSubString()

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

public static UTF8ArrSubString( $strarr[,  $start = '' ][,  $end = '' ][,  $unicode = true ]) : Return
Parameters
$strarr :

(string) The input array of characters.

$start : = ''

(int) the starting element of $strarr.

$end : = ''

(int) first element that will not be returned.

$unicode : = true

(boolean) True if we are in unicode mode, false otherwise.

Tags
public

static

Return values
Return

part of a string

UTF8ArrToLatin1()

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

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

(array) 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>

UTF8ArrToLatin1Arr()

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

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

(array) 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( $ta[,  $str = '' ][,  $forcertl = false ][,  $isunicode = true ],  &$currentfont) : array<string|int, mixed>
Parameters
$ta :

(array) array of characters composing the string.

$str : = ''

(string) string to process

$forcertl : = false

(bool) if 'R' forces RTL, if 'L' forces LTR

$isunicode : = true

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

$currentfont :

(array) 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( $arr[,  $str = '' ][,  $setbom = false ][,  $forcertl = false ][,  $isunicode = true ],  &$currentfont) : string
Parameters
$arr :

(array) array of unicode values.

$str : = ''

(string) string to manipulate (or empty value).

$setbom : = false

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

$forcertl : = false

(bool) if true forces RTL text direction

$isunicode : = true

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

$currentfont :

(array) 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( $str[,  $isunicode = true ],  &$currentfont) : array<string|int, mixed>
Parameters
$str :

(string) string to process.

$isunicode : = true

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

$currentfont :

(array) 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( $str[,  $setbom = false ][,  $forcertl = false ][,  $isunicode = true ],  &$currentfont) : string
Parameters
$str :

(string) string to manipulate.

$setbom : = false

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

$forcertl : = false

(bool) if true forces RTL text direction

$isunicode : = true

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

$currentfont :

(array) 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( $str[,  $isunicode = true ],  &$currentfont) : string
Parameters
$str :

(string) string to process.

$isunicode : = true

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

$currentfont :

(array) 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( $str[,  $setbom = false ][,  $isunicode = true ],  &$currentfont) : string
Parameters
$str :

(string) string to process.

$setbom : = false

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

$isunicode : = true

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

$currentfont :

(array) Reference to current font array.

Tags
author

Nicola Asuni

since
1.53.0.TC005

(2005-01-05)

public

static

Return values
string
 

© 2004-2021 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy