[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 TCPDF Fonts 2 3 TCPDF supports TrueTypeUnicode (UTF-8 Unicode), OpenTypeUnicode, TrueType, OpenType, Type1, CID-0 and Core (standard) fonts. 4 5 There are two ways to use a new font: embedding it in the PDF or not. When a font is not embedded, it is searched in the system. The advantage is that the PDF file is lighter; on the other hand, if it is not available, a substitution font is used. So it is preferable to ensure that the needed font is installed on the client systems. If the file is to be viewed by a large audience, it is recommended to embed. 6 7 The fonts that could be not embedded are only the standard core fonts and CID-0 fonts. 8 9 The PDF Core (standard) fonts are: 10 11 * courier : Courier 12 * courierb : Courier Bold 13 * courierbi : Courier Bold Italic 14 * courieri : Courier Italic 15 * helvetica : Helvetica 16 * helveticab : Helvetica Bold 17 * helveticabi : Helvetica Bold Italic 18 * helveticai : Helvetica Italic 19 * symbol : Symbol 20 * times : Times New Roman 21 * timesb : Times New Roman Bold 22 * timesbi : Times New Roman Bold Italic 23 * timesi : Times New Roman Italic 24 * zapfdingbats : Zapf Dingbats 25 26 Setting up a font for usage with TCPDF requires the following steps: 27 28 1. Convert all font filenames to lowercase. 29 30 2. Generate the font's metrics file. 31 * For Type1 font files this first step is not necessary because the AFM file is usually shipped with the font. In case you have only a metric file in PFM format, use the pfm2afm utility (fonts/utils/pfm2afm.exe) to get the AFM file. If you own a Type1 font in ASCII format (.pfa), you can convert it to binary format with Type 1 utilities. 32 * For TrueTypeUnicode or TrueType font files, use the the provided ttf2ufm utility (fonts/utils/ttf2ufm.exe): 33 34 $ ttf2ufm -a -F myfont.ttf 35 36 * For OpenTypeUnicode or OpenType font files, use the the provided ttf2ufm utility (fonts/utils/ttf2ufm.exe): 37 38 $ ttf2ufm -a -F myfont.otf 39 40 3. Run makefont.php script. 41 * For TrueTypeUnicode: 42 43 $ php -q makefont.php myfont.ttf myfont.ufm 44 45 * For OpenTypeUnicode: 46 47 $ php -q makefont.php myfont.otf myfont.ufm 48 49 * For TrueType: 50 51 $ php -q makefont.php myfont.ttf myfont.afm 52 53 * For OpenType: 54 55 $ php -q makefont.php myfont.otf myfont.afm 56 57 * For Type1: 58 59 $ php -q makefont.php myfont.pfb myfont.afm 60 61 You may also specify additional parameters: 62 63 MakeFont(string $fontfile, string $fmfile [, boolean $embedded [, $enc="cp1252" [, $patch=array()]]]) 64 65 * $fontfile : Path to the .ttf or .pfb file. 66 * $fmfile : Path to the .afm file for Type1 and TrueType or .ufm for TrueTypeUnicode. 67 * $embedded : Set to false to not embed the font, true otherwise (default). 68 * $enc : Name of the encoding table to use. Default value: cp1252. Omit this parameter for TrueType Unicode, OpenType Unicode and symbolic fonts like Symbol or ZapfDingBats. The encoding defines the association between a code (from 0 to 255) and a character. The first 128 are fixed and correspond to ASCII. The encodings are stored in .map files. Those available are: 69 o cp1250 (Central Europe) 70 o cp1251 (Cyrillic) 71 o cp1252 (Western Europe) 72 o cp1253 (Greek) 73 o cp1254 (Turkish) 74 o cp1255 (Hebrew) 75 o cp1257 (Baltic) 76 o cp1258 (Vietnamese) 77 o cp874 (Thai) 78 o iso-8859-1 (Western Europe) 79 o iso-8859-2 (Central Europe) 80 o iso-8859-4 (Baltic) 81 o iso-8859-5 (Cyrillic) 82 o iso-8859-7 (Greek) 83 o iso-8859-9 (Turkish) 84 o iso-8859-11 (Thai) 85 o iso-8859-15 (Western Europe) 86 o iso-8859-16 (Central Europe) 87 o koi8-r (Russian) 88 o koi8-u (Ukrainian) 89 Of course, the font must contain the characters corresponding to the chosen encoding. The encodings which begin with cp are those used by Windows; Linux systems usually use ISO. 90 * $patch : Optional modification of the encoding. Empty by default. This parameter gives the possibility to alter the encoding. Sometimes you may want to add some characters. For instance, ISO-8859-1 does not contain the euro symbol. To add it at position 164, pass array(164=>'Euro'). 91 92 4. Edit and copy resulting files by case: 93 * For embedded fonts: copy the resulting .php, .z and .ctg.z (if available) files to the TCPDF fonts directory. 94 * For CID-0 fonts (not embeddeed) you have to edit the .php file: 95 o change the font type to: $type='cidfont0'; 96 o set the default font width by adding the line: $dw=1000; 97 o remove the $enc, $file and $ctg variables definitions 98 o add one of the following blocks of text at the end of the file (depends by the language you are using - see the arialunicid0.php file for a working example): 99 + // Chinese Simplified 100 $enc='UniCNS-UTF16-H'; 101 $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'CNS1','Supplement'=>0); 102 include(dirname(__FILE__).'/uni2cid_ac16.php'); 103 104 + // Chinese Traditional 105 $enc='UniGB-UTF16-H'; 106 $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'GB1','Supplement'=>2); 107 include(dirname(__FILE__).'/uni2cid_ag15.php'); 108 109 + // Korean 110 $enc='UniKS-UTF16-H'; 111 $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'Korea1','Supplement'=>0); 112 include(dirname(__FILE__).'/uni2cid_ak12.php'); 113 114 + // Japanese 115 $enc='UniJIS-UTF16-H'; 116 $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'Japan1','Supplement'=>5); 117 include(dirname(__FILE__).'/uni2cid_aj16.php'); 118 119 o copy the .php file to the TCPDF fonts directory. 120 5. Rename php font files variations using the following schema: 121 * [basic-font-name-in-lowercase].php for regular font 122 * [basic-font-name-in-lowercase]b.php for bold variation 123 * [basic-font-name-in-lowercase]i.php for oblique variation 124 * [basic-font-name-in-lowercase]bi.php for bold oblique variation 125
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |