On Jul 12, 1:26 pm, "Marc J. Cawood" <
cawo...@gmail.com> wrote:
> I really struggled to find out why my stylesheets were being ignored
> until I realised you have to install fonts. Apparently basic fonts
> like Arial are not included.
That is true. The only fonts that are supported out of the box are
Helvetica, Times-Roman, Courier, Symbol, & Zapf-Dingbats. These are
required by the PDF spec for readers. I would just like to remind
everyone that when you specify a font you should always use a generic
fallback (e.g. font-family: Arial, sans-serif).
> ... the load_font.php script is tailor-made for Linux but not
> Windows. So, here is how you install the arial font - make a new
> batch file with the following contents:
>
> SET TT="C:\Program Files\TtfPt1\bin\ttf2pt1.exe"
> SET FF=C:\Windows\Fonts\
> SET DP=C:\Inetpub\wwwroot\kb\custom\dompdf
> %TT% -a -GAef -OW %FF%arial.ttf %DP%\lib\fonts\arial
> %TT% -a -GAef -OW %FF%arialbd.ttf %DP%\lib\fonts\arial-Bold
> %TT% -a -GAef -OW %FF%ariali.ttf %DP%\lib\fonts\arial-Italic
> %TT% -a -GAef -OW %FF%arialbi.ttf %DP%\lib\fonts\arial-BoldItalic
> PAUSE
>
> You should adapt the first 3 lines to point to you relevant file
> locations. You can download TtfPt1 here ->
http://tinyurl.com/mmrzbd
>
> Now, run this batch file and it should create 4 new .afm files in your
> DOMPDF/lib/fonts folder called arial*.afm.
Thanks for this info. Two more steps that are not listed above:
1) You have to modify dompdf/lib/fonts/dompdf_font_family_cache so
that the AFM files have valid references. If you're at all familiar
with PHP you should be able to make the appropriate modifications.
2) Ensure that the actual font files are also in the dompdf/lib/fonts
directory and match the names of the .afm files. If they're not DOMPDF
won't be able to find the fonts and the font-embedding won't work.
I would also note that there are some comments on the wiki about how
to get font loading working, see
http://code.google.com/p/dompdf/wiki/Installation.
The DOMPDF team will work out some instructions from the information
that's been posted to make sure that Windows users have some
documentation on how to add new fonts.
Moving forward, the next release of DOMPDF should include a Windows
executable for handling font loading (ttf2ufm). This is a modified
version of ttf2pt1 that will help enable UTF-8 support. We're also
considering creating a web-based tool to handle the creation of the
font metric files (.afm). If people are interested in this let us
know.
-b