[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/html2pdf/_tcpdf_5.0.002/fonts/utils/ -> README.TXT (source)

   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 and rename using the following schema:
  29            * [basic-font-name-in-lowercase].ttf for regular font
  30            * [basic-font-name-in-lowercase]b.ttf for bold variation
  31            * [basic-font-name-in-lowercase]i.ttf for oblique variation
  32            * [basic-font-name-in-lowercase]bi.ttf for bold oblique variation
  33  
  34     2. Generate the font's metrics file.
  35            * 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) 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.
  36            * For TrueTypeUnicode or TrueType font files, use the the provided ttf2ufm utility (fonts/utils/ttf2ufm):
  37  
  38              $ ttf2ufm -a -F myfont.ttf
  39  
  40            * For OpenTypeUnicode or OpenType font files, use the the provided ttf2ufm utility (fonts/utils/ttf2ufm):
  41  
  42              $ ttf2ufm -a -F myfont.otf
  43  
  44     3. Run makefont.php script.
  45            * For TrueTypeUnicode:
  46  
  47              $ php -q makefont.php myfont.ttf myfont.ufm
  48  
  49            * For OpenTypeUnicode:
  50  
  51              $ php -q makefont.php myfont.otf myfont.ufm
  52  
  53            * For TrueType:
  54  
  55              $ php -q makefont.php myfont.ttf myfont.afm
  56  
  57            * For OpenType:
  58  
  59              $ php -q makefont.php myfont.otf myfont.afm
  60  
  61            * For Type1:
  62  
  63              $ php -q makefont.php myfont.pfb myfont.afm
  64  
  65        You may also specify additional parameters:
  66  
  67        MakeFont(string $fontfile, string $fmfile [, boolean $embedded [, $enc="cp1252" [, $patch=array()]]])
  68  
  69            * $fontfile : Path to the .ttf or .pfb file.
  70            * $fmfile : Path to the .afm file for Type1 and TrueType or .ufm for TrueTypeUnicode.
  71            * $embedded : Set to false to not embed the font, true otherwise (default).
  72            * $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:
  73                  o cp1250 (Central Europe)
  74                  o cp1251 (Cyrillic)
  75                  o cp1252 (Western Europe)
  76                  o cp1253 (Greek)
  77                  o cp1254 (Turkish)
  78                  o cp1255 (Hebrew)
  79                  o cp1257 (Baltic)
  80                  o cp1258 (Vietnamese)
  81                  o cp874 (Thai)
  82                  o iso-8859-1 (Western Europe)
  83                  o iso-8859-2 (Central Europe)
  84                  o iso-8859-4 (Baltic)
  85                  o iso-8859-5 (Cyrillic)
  86                  o iso-8859-7 (Greek)
  87                  o iso-8859-9 (Turkish)
  88                  o iso-8859-11 (Thai)
  89                  o iso-8859-15 (Western Europe)
  90                  o iso-8859-16 (Central Europe)
  91                  o koi8-r (Russian)
  92                  o koi8-u (Ukrainian)
  93              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.
  94            * $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').
  95  
  96     4. Edit and copy resulting files by case:
  97            * For embedded fonts: copy the resulting .php, .z and .ctg.z (if available) files to the TCPDF fonts directory.
  98            * For not-embedding the font, edit the .php file and comment the $file entry.
  99            * For CID-0 fonts (not embeddeed) you have to edit the .php file:
 100                  o change the font type to: $type='cidfont0';
 101                  o set the default font width by adding the line: $dw=1000;
 102                  o remove the $enc, $file and $ctg variables definitions
 103                  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):
 104                        + // Chinese Simplified
 105                          $enc='UniCNS-UTF16-H';
 106                          $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'CNS1','Supplement'=>0);
 107                          include(dirname(__FILE__).'/uni2cid_ac16.php');
 108  
 109                        + // Chinese Traditional
 110                          $enc='UniGB-UTF16-H';
 111                          $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'GB1','Supplement'=>2);
 112                          include(dirname(__FILE__).'/uni2cid_ag15.php');
 113  
 114                        + // Korean
 115                          $enc='UniKS-UTF16-H';
 116                          $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'Korea1','Supplement'=>0);
 117                          include(dirname(__FILE__).'/uni2cid_ak12.php');
 118  
 119                        + // Japanese
 120                          $enc='UniJIS-UTF16-H';
 121                          $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'Japan1','Supplement'=>5);
 122                          include(dirname(__FILE__).'/uni2cid_aj16.php');
 123  
 124                  o copy the .php file to the TCPDF fonts directory.
 125     5. Rename php font files variations using the following schema:
 126            * [basic-font-name-in-lowercase].php for regular font
 127            * [basic-font-name-in-lowercase]b.php for bold variation
 128            * [basic-font-name-in-lowercase]i.php for oblique variation
 129            * [basic-font-name-in-lowercase]bi.php for bold oblique variation
 130  


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1