You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jeremias Maerki <de...@jeremias-maerki.ch> on 2006/09/19 21:39:51 UTC

Re: Unicode Fonts!!!! (don't give up on us!)

Please wait a second before you give up and spread a wrong impression
that FOP isn't up to the task. The bits of information that were given
to you contained all the hints that were necessary to accomplish your
goal. But I can imagine it is difficult to get it all together. So let
me give you a step-by-step guide to a full Polish document with Apache
FOP:

1. Obtain a font that contains all the necessary characters.

PDF defines a set of 14 so-called base fonts (Helvetica, Times etc.)
which are expected to be available on every PDF-capable product, viewer
or producer. These fonts are defined as Type 1 fonts with a maximum of
255 distinctive glyphs. And this set does not include every character
you need for your Polish documents. That's the reason why Michael Bruns
cannot view your iText-generated PDF properly. Your Acrobat Reader maps
the Helvetica font to an Arial font which has all the necessary
characters, but Michael's system only supports the basic base 14 font
set as required by the PDF specification. So you can't be sure that your
PDF generated using iText can be viewed correctly on every system as you
depend on the fact that the viewer has a font with all the characters
available. That's why it's important to embed a font in the PDF that
contains all the necessary characters. You can make sure every PDF
viewer uses the right font that you want used. And this is best done
using a TrueType font.

A free set of TrueType fonts can be obtained from the D�j�Vu project,
for example:
http://dejavu.sourceforge.net

2. Generate the XML font metrics file for each font you'd like to use.

This procedure is described in
http://xmlgraphics.apache.org/fop/0.92/fonts.html
or
http://xmlgraphics.apache.org/fop/0.20.5/fonts.html
depending on the FOP version you're using. I know this step is awkward,
but for the moment FOP still needs it. We hope that'll change soon.
There are efforts in that direction.

3. Configure the font in your FOP configuration file.

A minimal configuration file for FOP 0.92beta would look like this
(assuming you use DejaVuSans as a font):
<?xml version="1.0" encoding="UTF-8"?>
<fop>
  <renderers>
    <renderer mime="application/pdf">
      <fonts>
        <font metrics-url="/fonts/dejavu-ttf-2.5/DejaVuSans.ttf.xml" embed-url="fonts/dejavu-ttf-2.5/DejaVuSans.ttf">
          <font-triplet name="DejaVuSans" style="normal" weight="normal"/>
        </font>
      </fonts>
    </renderer>
  </renderers>
</fop>

4. Run FOP (with your configuration file).

On the command-line:
fop -c myconfig.xml -fo myfile.fo -pdf myfile.pdf

For embedding in Java, see the documentation.

As a proof that this actually works, please see the attached files.

BTW, I recommend you encode your XML files using UTF-8 so you have the
full Unicode spectrum available and don't have to reply on using
character entities. And yes, it works on a Mac.

On 19.09.2006 14:26:32 Paul Loy wrote:
> Hi all,
> 
> thank you for all your comments and help. I am still unable to get a 
> single character to come out in polish. I have, therefore, admitted 
> defeat and am going to ditch the old nasty code in favour of iText, a 
> free PDF generating library. It was so easy to get the characters to 
> display in the PDF using this:

<snip/>
> 
> and that's it! I've attached the PDF too.
> 
> I like the fact that FOP allows XSLT transformations into PDF, a very 
> powerful feature, but I can't do with it's pitiful unicode support. Make 
> it simple people! All we want to have to do is say: "this is iso-8859-2, 
> can you output the correct characters please" and for FOP to say "no 
> problem mate, if the font supports it"...
> 
> Alas, FOP is not for me at the moment. Perhaps when they sort the 
> unicode issues out it'll be worth coming back to. Good luck one and all 
> with your FOPing, I hope you manage where I have failed.

<snip/>


Jeremias Maerki