Blame | Letzte Änderung | Log anzeigen | RSS feed
<html><head><title>html2ps/html2pdf FAQ</title><link rel="stylesheet" type="text/css" medial="all" title="Default" href="css/help.css"/></head><body><h1>HOWTO: Install custom fonts</h1><p><a href="index.html">Back to table of contents</a></p><div>Keep in mind that most likely you will be using FPDF output method, as it covers 90% of your needs.Installing fonts for PDFLIB and Postscript output methods is required only if you're usingnon-default output driver.</div><ol><li><a href="#fpdf">FPDF</a><li><a href="#postscript">Postscript</a></li><li><a href="#ps2pdf">Postscript (PS2PDF)</a></li><li><a href="#pdflib">PDFLIB</a></ol><h2 id="fpdf">FPDF output method</h2>Let's assume that you're going to install Trebuchet MS for the FPDF output method.<ol><li>Copy font files (<tt>trebuc.ttf</tt>, <tt>treducdb.ttf</tt>, <tt>trebucbi.ttf</tt> and <tt>trebucit.ttf</tt>)to TTF_FONTS_REPOSITORY directory (by default it points to 'fonts' subdirectory)</li><li><a title="How to get AFM files?" href="howto_afm.html">Generate font metrics file</a> for these fonts filesand put it into the same directory. Note that metrics file should have the same name as font file andextension <tt>.afm</tt> (this step is optional if you're using a html2ps version more recent than 1.9.4)</li><li>Register new font family in html2ps.config: add the following lines to <tt>html2ps.config</tt> inthe FONTS-PDF section (between <tt><fonts-pdf></tt> and <tt></fonts-pdf></tt> tags):<pre><family name="Trebuchet MS"><normal normal="TrebuchetMS" italic="TrebuchetMS-Italic" oblique="TrebuchetMS-Italic"/><bold normal="TrebuchetMS-Bold" italic="TrebuchetMS-Bold-Italic" oblique="TrebuchetMS-Bold-Italic"/></family></pre><li>Register font files: add the following to the FONTS-PDF section:<pre><ttf typeface="TrebuchetMS" embed="0" file="trebuc.ttf"/><ttf typeface="TrebuchetMS-Bold" embed="0" file="trebucbd.ttf"/><ttf typeface="TrebuchetMS-Italic" embed="0" file="trebucit.ttf"/><ttf typeface="TrebuchetMS-Bold-Italic" embed="0" file="trebucbi.ttf"/></pre>Note that you may want to replace <tt>embed="0"</tt> with <tt>embed="1"</tt> if you intendto distribute generated PDF to users without Trebuchet MS font installed in their machines.</li></ol><h2 id="postscript">Postscript output method</h2>Say you want to see the fancy "Trebuchet MS" font in your generatedpostscript...<ol><li> First of all, TrueType-compatible Ghostscript is a must. Most Ghostsciptdistributions are TrueType compatible. If you're not sure, ask your systemadministrator. If your GS is not True-Type compatible, consider building fromsource using require options. <br><br></li><li> Find the file coresponding to "Trebuchet MS". Assuming you'reusing some version of Windows on your home machine, you can do it by opening"Control Panel ... Fonts" and checking the properties of the chosenfont. At the top of the property page you'll see the file name - <tt>trebuc.ttf</tt>,in our case. <br><br></li><li> Find the font files corresponding to the bold, italic and bold italic versionsof this font. Probably, it will be:<br/>"Trebuchet MS Bold" -- <tt>trebucbd.ttf</tt>,<br/>"Trebuchet MS Italic" -- <tt>trebucit.ttf</tt>,<br/>"Trebuchet MS Bold Italic" -- <tt>trebucbi.ttf</tt><br><br/></li><li>Copy these files from the Windows fonts directory (probably C:\Windows\Fonts)to the Ghostscript fonts directory (probably C:\gs\fonts). <br><br></li><li>Modify the Ghostscript fontmap file (probably C:\gs\gs8.51\lib\Fontmap,assuming you're using Ghostscript version 8.51), adding the folowing lines:<pre>/TrebuchetMS (trebuc.ttf) ;/TrebuchetMS-Italic (trebucit.ttf) ;/TrebuchetMS-Bold (trebucbd.ttf) ;/TrebuchetMS-Bold-Italic (trebucbi.ttf) ;</pre>Note you can write almost anything after the / assuming it won't interferewith other font names. Say:<pre>/MyCoolFont1 (trebuc.ttf) ;/MyCoolFont2 (trebucit.ttf) ;/MyCoolFont3 (trebucbd.ttf) ;/MyCoolFont4 (trebucbi.ttf) ;</pre></li><li>Register the above font names in the script config file. Add the followinglines to <tt>html2ps.config</tt> in the FONTS section (between <tt><fonts></tt>and <tt></fonts></tt> tags)<pre><family name="Trebuchet MS"><normal normal="TrebuchetMS" italic="TrebuchetMS-Italic" oblique="TrebuchetMS-Italic"/><bold normal="TrebuchetMS-Bold" italic="TrebuchetMS-Bold-Italic" oblique="TrebuchetMS-Bold-Italic"/></family></pre>Of course, the modified file should be uploaded to the server where the workingscript reside. <br><br><li>Register the metric files of the new TrueType fonts. To do it, add the following to the FONT section:<pre><metrics typeface="TrebuchetMS" file="trebuc"/><metrics typeface="TrebuchetMS-Italic" file="trebucit"/><metrics typeface="TrebuchetMS-Bold" file="trebucbd"/><metrics typeface="TrebuchetMS-BoldItalic" file="trebucbi"/></pre>In this case, the "file" value refers to the name of the font metric file (.afm) you've<a title="How to get AFM files?" href="howto_afm.html">generated</a>. The ".afm" extensionas appended automatically; files are searched in the directory specified by TYPE1_FONTS_REPOSITORY configurationconstant (see your config.inc.php file).</li><li> Now, the following example should be rendered using Trebuchet MS font:<pre><BIG style="font-family: 'Trebuchet MS'">ABCDEFGH</BIG><br><BIG style="font-family: 'Trebuchet MS'; font-weight: bold;">ABCDEFGH</BIG><br><BIG style="font-family: 'Trebuchet MS'; font-style: italic;">ABCDEFGH</BIG><br><BIG style="font-family: 'Trebuchet MS'; font-weight: bold; font-style: italic;">ABCDEFGH</BIG><br></pre></li></ol><h2 id="ps2pdf">PS2PDF output method</h2><p>Take the steps described above with only this difference: all Ghostscript-relateddirectories are on your server where the script resides. Ask your hoster/systemadministrator about the exact location of Ghostscript.</p><h2 id="pdflib">PDFLIB output method</h2><p>Please refer to PDFLib Documentation.</p></body></html>