1<html>
2<head>
3<title>html2ps/html2pdf FAQ</title>
4<link rel="stylesheet" type="text/css" medial="all" title="Default" href="css/help.css"/>
5</head>
6<body>
7<h1>HOWTO: Install custom fonts</h1>
8<p><a href="index.html">Back to table of contents</a></p>
9
10<div>
11Keep in mind that most likely you will be using FPDF output method, as it covers 90% of your needs.
12Installing fonts for PDFLIB and Postscript output methods is required only if you're using
13non-default output driver.
14</div>
15
16<ol>
17  <li><a href="#fpdf">FPDF</a>
18  <li><a href="#postscript">Postscript</a></li>
19  <li><a href="#ps2pdf">Postscript (PS2PDF)</a></li>
20  <li><a href="#pdflib">PDFLIB</a>
21</ol>
22
23<h2 id="fpdf">FPDF output method</h2>
24Let's assume that you're going to install Trebuchet MS for the FPDF output method.
25<ol>
26<li>Copy font files (<tt>trebuc.ttf</tt>, <tt>treducdb.ttf</tt>, <tt>trebucbi.ttf</tt> and <tt>trebucit.ttf</tt>)
27to TTF_FONTS_REPOSITORY directory (by default it points to 'fonts' subdirectory)</li>
28<li><a title="How to get AFM files?" href="howto_afm.html">Generate font metrics file</a> for these fonts files
29and put it into the same directory. Note that metrics file should have the same name as font file and
30extension <tt>.afm</tt> (this step is optional if you're using a html2ps version more recent than 1.9.4)</li>
31<li>Register new font family in html2ps.config: add the following lines to <tt>html2ps.config</tt> in
32the FONTS-PDF section (between <tt>&lt;fonts-pdf&gt;</tt> and <tt>&lt;/fonts-pdf&gt;</tt> tags):
33<pre>
34  &lt;family name=&quot;Trebuchet MS&quot;&gt;
35    &lt;normal normal=&quot;TrebuchetMS&quot; italic=&quot;TrebuchetMS-Italic&quot; oblique=&quot;TrebuchetMS-Italic&quot;/&gt;
36    &lt;bold normal=&quot;TrebuchetMS-Bold&quot; italic=&quot;TrebuchetMS-Bold-Italic&quot; oblique=&quot;TrebuchetMS-Bold-Italic&quot;/&gt;
37  &lt;/family&gt;
38</pre>
39<li>
40Register font files: add the following to the FONTS-PDF section:
41<pre>
42  &lt;ttf typeface=&quot;TrebuchetMS&quot;             embed=&quot;0&quot; file=&quot;trebuc.ttf&quot;/&gt;
43  &lt;ttf typeface=&quot;TrebuchetMS-Bold&quot;        embed=&quot;0&quot; file=&quot;trebucbd.ttf&quot;/&gt;
44  &lt;ttf typeface=&quot;TrebuchetMS-Italic&quot;      embed=&quot;0&quot; file=&quot;trebucit.ttf&quot;/&gt;
45  &lt;ttf typeface=&quot;TrebuchetMS-Bold-Italic&quot; embed=&quot;0&quot; file=&quot;trebucbi.ttf&quot;/&gt;
46</pre>
47Note that you may want to replace <tt>embed=&quot;0&quot;</tt> with <tt>embed=&quot;1&quot;</tt> if you intend
48to distribute generated PDF to users without Trebuchet MS font installed in their machines.
49</li>
50</ol>
51
52<h2 id="postscript">Postscript output method</h2>
53Say you want to see the fancy &quot;Trebuchet MS&quot; font in your generated
54postscript...
55<ol>
56  <li> First of all, TrueType-compatible Ghostscript is a must. Most Ghostscipt
57    distributions are TrueType compatible. If you're not sure, ask your system
58    administrator. If your GS is not True-Type compatible, consider building from
59    source using require options. <br>
60    <br>
61  </li>
62  <li> Find the file coresponding to &quot;Trebuchet MS&quot;. Assuming you're
63    using some version of Windows on your home machine, you can do it by opening
64    &quot;Control Panel ... Fonts&quot; and checking the properties of the chosen
65    font. At the top of the property page you'll see the file name - <tt>trebuc.ttf</tt>,
66    in our case. <br>
67    <br>
68  </li>
69  <li> Find the font files corresponding to the bold, italic and bold italic versions
70    of this font. Probably, it will be:<br/>
71    &quot;Trebuchet MS Bold&quot; -- <tt>trebucbd.ttf</tt>,<br/>
72    &quot;Trebuchet MS Italic&quot; -- <tt>trebucit.ttf</tt>,<br/>
73    &quot;Trebuchet MS Bold Italic&quot; -- <tt>trebucbi.ttf</tt><br>
74    <br/>
75  </li>
76  <li>Copy these files from the Windows fonts directory (probably C:\Windows\Fonts)
77    to the Ghostscript fonts directory (probably C:\gs\fonts). <br>
78    <br>
79  </li>
80  <li>Modify the Ghostscript fontmap file (probably C:\gs\gs8.51\lib\Fontmap,
81    assuming you're using Ghostscript version 8.51), adding the folowing lines:
82    <pre>
83/TrebuchetMS (trebuc.ttf) ;
84/TrebuchetMS-Italic (trebucit.ttf) ;
85/TrebuchetMS-Bold (trebucbd.ttf) ;
86/TrebuchetMS-Bold-Italic (trebucbi.ttf) ;
87</pre>
88    Note you can write almost anything after the / assuming it won't interfere
89    with other font names. Say:
90    <pre>
91/MyCoolFont1 (trebuc.ttf) ;
92/MyCoolFont2 (trebucit.ttf) ;
93/MyCoolFont3 (trebucbd.ttf) ;
94/MyCoolFont4 (trebucbi.ttf) ;
95</pre>
96  </li>
97  <li>Register the above font names in the script config file. Add the following
98    lines to <tt>html2ps.config</tt> in the FONTS section (between <tt>&lt;fonts&gt;</tt>
99    and <tt>&lt;/fonts&gt;</tt> tags)
100    <pre>
101  &lt;family name=&quot;Trebuchet MS&quot;&gt;
102    &lt;normal normal=&quot;TrebuchetMS&quot; italic=&quot;TrebuchetMS-Italic&quot; oblique=&quot;TrebuchetMS-Italic&quot;/&gt;
103    &lt;bold normal=&quot;TrebuchetMS-Bold&quot; italic=&quot;TrebuchetMS-Bold-Italic&quot; oblique=&quot;TrebuchetMS-Bold-Italic&quot;/&gt;
104  &lt;/family&gt;
105</pre>
106    Of course, the modified file should be uploaded to the server where the working
107    script reside. <br>
108    <br>
109  <li>Register the metric files of the new TrueType fonts. To do it, add the following to the FONT section:
110<pre>
111    &lt;metrics typeface=&quot;TrebuchetMS&quot; file=&quot;trebuc&quot;/&gt;
112    &lt;metrics typeface=&quot;TrebuchetMS-Italic&quot; file=&quot;trebucit&quot;/&gt;
113    &lt;metrics typeface=&quot;TrebuchetMS-Bold&quot; file=&quot;trebucbd&quot;/&gt;
114    &lt;metrics typeface=&quot;TrebuchetMS-BoldItalic&quot; file=&quot;trebucbi&quot;/&gt;
115</pre>
116  In this case, the &quot;file&quot; value refers to the name of the font metric file (.afm) you've
117  <a title="How to get AFM files?" href="howto_afm.html">generated</a>. The &quot;.afm&quot; extension
118  as appended automatically; files are searched in the directory specified by TYPE1_FONTS_REPOSITORY configuration
119  constant (see your config.inc.php file).
120  </li>
121  <li> Now, the following example should be rendered using Trebuchet MS font:
122    <pre>
123&lt;BIG style=&quot;font-family: 'Trebuchet MS'&quot;&gt;ABCDEFGH&lt;/BIG&gt;&lt;br&gt;
124&lt;BIG style=&quot;font-family: 'Trebuchet MS'; font-weight: bold;&quot;&gt;ABCDEFGH&lt;/BIG&gt;&lt;br&gt;
125&lt;BIG style=&quot;font-family: 'Trebuchet MS'; font-style: italic;&quot;&gt;ABCDEFGH&lt;/BIG&gt;&lt;br&gt;
126&lt;BIG style=&quot;font-family: 'Trebuchet MS'; font-weight: bold; font-style: italic;&quot;&gt;ABCDEFGH&lt;/BIG&gt;&lt;br&gt;
127</pre>
128  </li>
129</ol>
130
131<h2 id="ps2pdf">PS2PDF output method</h2>
132
133<p>Take the steps described above with only this difference: all Ghostscript-related
134  directories are on your server where the script resides. Ask your hoster/system
135  administrator about the exact location of Ghostscript.</p>
136
137<h2 id="pdflib">PDFLIB output method</h2>
138<p>Please refer to PDFLib Documentation.</p>
139
140</body>
141</html>