xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Radermacher <ste...@zaister.de>
Subject Problem embedding fonts in PDF
Date Tue, 26 Jul 2016 15:07:25 GMT
Hello, I am looking for some help on embedding fonts with FOP (version
2.1). I am working on program that uses FOP to create PDF files.
Unfortunately the standard fonts included in FOP do not have glyphs for
many international character that we would like to be able to include in
our generated PDFs. So I have started on looking to embed custom fonts.
I am trying this with a free font called Gandhi Sans for now.

I think I have set up the stuff as the documentation indicates, but my
font configuration gets ignored and FOP produces a lot of warnings
listing: "Font "Gandhi Sans,normal,400" not found. Substituting with

My fop.xconf file looks as follows (relevant parts only):
-------- snip --------
<fop version="1.0">
    <renderer mime="application/pdf">

        <font kerning="yes" embed-url="Gandhi_Sans_Regular.otf">
          <font-triplet name="Gandhi Sans" style="normal"
            weight="normal" />
        <font kerning="yes" embed-url="Gandhi_Sans_Bold.otf">
          <font-triplet name="Gandhi Sans" style="normal"
            weight="bold" />
        <font kerning="yes" embed-url="Gandhi_Sans_Italic.otf">
          <font-triplet name="Gandhi Sans" style="italic"
            weight="normal" />
        <font kerning="yes" embed-url="Gandhi_Sans_Bold_Italic.otf">
          <font-triplet name="Gandhi Sans" style="italic"
            weight="bold" />
-------- snip --------

I do have the weird feeling that the file gets ignored somehow, since
even when I modify it to point to a non-existent font file or even to
have an invalid xml structure, I'm not getting any errors or exceptions
about this. Anyway, the fonts are located in a folder "fonts" that is on
the same level as the fop.xconf file. I have tried using full paths or
full URIs with file:// prefix to indicate the font files, but no change.
I have also tried with and without trailing slash for the base and
font-base properties.

I'm adding the file in my Java code like this:
-------- snip --------
FopFactoryBuilder builder;
File userConfigFile = new
    + File.separator + "fop.xconf");
  builder = new FopFactoryBuilder(userConfigFile.toURI());
catch (Exception e)
  [exception handling]


FopFactory fopFactory = builder.build();
FOUserAgent userAgent = fopFactory.newFOUserAgent();
    new FOPEventListener());

[set some userAgent attributes]

  Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);

  TransformerFactory transFactory = TransformerFactory.newInstance();
  Transformer transformer = transFactory.newTransformer(xsltSource);
  transformer.setErrorListener(new FOPErrorListener());
    new SAXResult(fop.getDefaultHandler()));
catch (TransformerException | FOPException | IOException e)
  [exception handling]
-------- snip --------

What am I doing wrong?

Kind regards and thanks for any help,

To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org

View raw message