TCPDF_FONTS

class

TCPDF_FONTS Font methods for TCPDF library.

package

com.tecnick.tcpdf

version 1.1.0
author

Nicola Asuni - info@tecnick.com

Methods

Return fonts path

_getfontpath(): string
static
public

static

Response

string

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

_getTrueTypeFontSubset(string $font,array $subsetchars): string
static
author

Nicola Asuni

since 5.2.000

(2010-06-02)

public

static

Arguments

$font

string

TrueType font data.

$subsetchars

array

Array of used characters (the glyphs to keep).

Response

string

A subset of TrueType font data without the unused glyphs.

Returs the checksum of a TTF table.

_getTTFtableChecksum(string $table,integer $length): integer
static
author

Nicola Asuni

since 5.2.000

(2010-06-02)

public

static

Arguments

$table

string

table to check

$length

integer

length of table in bytes

Response

integer

checksum

Outputs font widths

_putfontwidths(array $font,integer $cidoffset): string
static
author

Nicola Asuni

since 4.4.000

(2008-12-07)

public

static

Arguments

$font

array

font data

$cidoffset

integer

offset for CID values

Response

string

PDF command string for font widths

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

addTTFfont(string $fontfile,string $fonttype = '',string $enc = '',integer $flags = 32,string $outpath = '',integer $platid = 3,integer $encid = 1,boolean $addcbbox = false,boolean $link = false): string|false
static
author

Nicola Asuni

since 5.9.123

(2010-09-30)

public

static

Arguments

$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

integer

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

integer

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

integer

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

boolean

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

$link

boolean

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

Response

string|false

TCPDF font name or boolean false in case of error.

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

arrUTF8ToUTF16BE(array $unicode,boolean $setbom = false): string
static

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

protected
author

Nicola Asuni

since 2.1.000

(2008-01-08)

public

static

Arguments

$unicode

array

array containing UTF-8 unicode values

$setbom

boolean

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

Response

string

Return font full path

getFontFullPath(string $file,string $fontdir = false): string
static
author

Nicola Asuni

since 6.0.025
public

static

Arguments

$file

string

Font file name.

$fontdir

string

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

Response

string

Font full path or empty string

Get a reference font size.

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

static

Arguments

$size

string

String containing font size value.

$refsize

float

Reference font size in points.

Response

float

value in points

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

getUniord(string $uch): integer
static

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

author

Nicola Asuni

public

static

Arguments

$uch

string

character string to process.

Response

integer

Unicode value

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

UniArrSubString(array<mixed,string> $uniarr,integer $start = '',integer $end = ''): string
static
since 4.5.037

(2009-04-07)

public

static

Arguments

$uniarr

array<mixed,string>

The input array of characters.

$start

integer

the starting element of $strarr.

$end

integer

first element that will not be returned.

Response

string

Return part of a string

Returns the unicode caracter specified by the value

unichr(integer $c,boolean $unicode = true): string
static
since 2.3.000

(2008-03-05)

public

static

Arguments

$c

integer

UTF-8 value

$unicode

boolean

True if we are in unicode mode, false otherwise.

Response

string

Returns the specified character.

Returns the unicode caracter specified by ASCII value

unichrASCII(integer $c): string
static
public

static

Arguments

$c

integer

UTF-8 value

Response

string

Returns the specified character.

Returns the unicode caracter specified by UTF-8 value

unichrUnicode(integer $c): string
static
public

static

Arguments

$c

integer

UTF-8 value

Response

string

Returns the specified character.

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

uniord(string $uch): integer
static
public

static

Arguments

$uch

string

character string to process.

Response

integer

Unicode value

Update the CIDToGIDMap string with a new value.

updateCIDtoGIDmap(string $map,integer $cid,integer $gid): string
static
author

Nicola Asuni

since 5.9.123

(2011-09-29)

public

static

Arguments

$map

string

CIDToGIDMap.

$cid

integer

CID value.

$gid

integer

GID value.

Response

string

CIDToGIDMap.

Convert an array of UTF8 values to array of unicode characters

UTF8ArrayToUniArray(array $ta,boolean $isunicode = true): array
static
since 4.5.037

(2009-04-07)

public

static

Arguments

$ta

array

The input array of UTF8 values.

$isunicode

boolean

True for Unicode mode, false otherwise.

Response

array

Return array of unicode characters

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

UTF8ArrSubString(array<mixed,string> $strarr,integer $start = '',integer $end = '',boolean $unicode = true): string
static
public

static

Arguments

$strarr

array<mixed,string>

The input array of characters.

$start

integer

the starting element of $strarr.

$end

integer

first element that will not be returned.

$unicode

boolean

True if we are in unicode mode, false otherwise.

Response

string

Return part of a string

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

UTF8ArrToLatin1(array $unicode): string
static
author

Nicola Asuni

since 4.8.023

(2010-01-15)

public

static

Arguments

$unicode

array

array containing UTF-8 unicode values

Response

string

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

UTF8ArrToLatin1Arr(array $unicode): array
static
author

Nicola Asuni

since 4.8.023

(2010-01-15)

public

static

Arguments

$unicode

array

array containing UTF-8 unicode values

Response

array

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

utf8Bidi(array $ta,string $str,boolean $forcertl,boolean $isunicode,array &$currentfont): array
static
author

Nicola Asuni

since 2.4.000

(2008-03-06)

public

static

Arguments

$ta

array

array of characters composing the string.

$str

string

string to process

$forcertl

boolean

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

$isunicode

boolean

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

$currentfont

array

Reference to current font array.

Response

array

of unicode chars

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

utf8StrArrRev(array $arr,string $str,boolean $setbom,boolean $forcertl,boolean $isunicode,array &$currentfont): string
static
author

Nicola Asuni

since 4.9.000

(2010-03-27)

public

static

Arguments

$arr

array

array of unicode values.

$str

string

string to manipulate (or empty value).

$setbom

boolean

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

$forcertl

boolean

if true forces RTL text direction

$isunicode

boolean

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

$currentfont

array

Reference to current font array.

Response

string

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

UTF8StringToArray(string $str,boolean $isunicode,array &$currentfont): array
static
author

Nicola Asuni

public

static

Arguments

$str

string

string to process.

$isunicode

boolean

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

$currentfont

array

Reference to current font array.

Response

array

containing codepoints (UTF-8 characters values)

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

utf8StrRev(string $str,boolean $setbom,boolean $forcertl,boolean $isunicode,array &$currentfont): string
static
author

Nicola Asuni

since 2.1.000

(2008-01-08)

public

static

Arguments

$str

string

string to manipulate.

$setbom

boolean

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

$forcertl

boolean

if true forces RTL text direction

$isunicode

boolean

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

$currentfont

array

Reference to current font array.

Response

string

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

UTF8ToLatin1(string $str,boolean $isunicode,array &$currentfont): string
static
since 3.2.000

(2008-06-23)

public

static

Arguments

$str

string

string to process.

$isunicode

boolean

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

$currentfont

array

Reference to current font array.

Response

string

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

UTF8ToUTF16BE(string $str,boolean $setbom,boolean $isunicode,array &$currentfont): string
static
author

Nicola Asuni

since 1.53.0.TC005

(2005-01-05)

public

static

Arguments

$str

string

string to process.

$setbom

boolean

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

$isunicode

boolean

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

$currentfont

array

Reference to current font array.

Response

string

Properties

Static cache used for speed up uniord performances

cache_uniord :
static
protected

Type(s)