Bug 46371 - Fonts not found for SVG texts (when not in C:\WINNT\Fonts)
Summary: Fonts not found for SVG texts (when not in C:\WINNT\Fonts)
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: svg (show other bugs)
Version: 0.95
Hardware: PC Windows 2000
: P3 normal
Target Milestone: ---
Assignee: fop-dev
Depends on: 46374
  Show dependency tree
Reported: 2008-12-10 02:02 UTC by M.H.
Modified: 2012-04-07 01:52 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description M.H. 2008-12-10 02:02:48 UTC
I configured FOP to use custom fonts with their TTF files being in a custom directory - and not C:\WINNT\Fonts (reason: license restrictions only allows usage of some fonts in the FOP application and not in any other Windows applications, like e.g. Word). This works flawlessly for FOP texts.

However, SVGs are also included (referenced/linked) in the XSLs. And for texts in these SVGs, the fonts are only used/found if they are stored in C:\WINNT\Fonts! It seems that FOP doesn't tell its SVG engine (Batik) where to find the fonts, as FOP itself knows it from its configuration XML. Is Batik using the font configuartion of FOP at all or is there some additional configuration possible to tell FOP to set its font configuration also for Batik?
Comment 1 Jeremias Maerki 2008-12-10 02:53:53 UTC
This is a known issue and it's not primarily a FOP issue, but a Batik issue. I've recently documented that particularity although I still haven't re-published the updated website. For your convenience here's an excerpt:


<section id="svg-font-selection">
          <title>Font selection notes</title>
            Apache Batik uses the AWT/Java2D subsystem as font source while FOP has its on font
            subsystem. Great care has been taken that font selection does the best possible choices.
            But it must be noted when creating PDF or PostScript that a font used in SVG graphics
            needs to be registered with the operating system as well as in FOP's configuration.
            By using FOP's font auto-detection, you simply have to install the font in the operating
            system and not care about anything else. This is less of an issue if you create
            formats like TIFFs, PNGs or PCL because in these cases SVG graphics are usually rendered
            to bitmaps which means that on both sides (Batik and FOP), AWT/Java2D is used as the
            single font source.
            Whenever an SVG is converted into a PDF or PostScript file, the font that has been used
            inside Batik has to be mapped to a font used by the actual output format. Features like
            font substitution in FOP may need to be taken into account but can also be an advantage
            when working around font mapping issues. Like for XSL-FO content, you'll get a warning
            if a particular font could not be found and had to be substituted, or if a particular
            glyph is missing in a font.

Anyway, Batik would need to be changed to allow plugging in an external font source like FOP's font configuration. There's no easy solution to this. It would mean working with the Batik developers and quite a bit of work. Don't expect anyone to do that for you in the near future. I don't see a work-around other than installing the necessary font in your operating system to make them available to Batik.

I know there is a code section in Batik that can load a TrueType font from an external file (not installed in the operating system), so it might be possible to specify the location of a font somehow. But I don't know how that works and if it's really possible. You will have to ask on batik-users.

I guess we can keep this issue around as a reminder. But given the amount of work expected compared to the expected gain it is realistic to assume this won't be implemented soon.
Comment 2 M.H. 2008-12-10 03:07:52 UTC
I tried to set the custom TTF fonts in a custom fontconfig.properties for the Java application.

java ... -Dsun.awt.fontconfig=C:/test/fontconfig.properties

This works in a test Java application (i.e.: I can uses the TTF font which is not in C:\WINNT\Fonts in Java by creating a Font object with the correct font family name and sub name). UNfortunately, Batik seems to ignore this.

So, this seems to be an issue of Batik not offering an API (for FOP) to set custom font sources?
Comment 3 Jeremias Maerki 2008-12-10 03:15:38 UTC
Basically, yes. If I remember correctly, there are hints in the code that something like this could be added. But when I looked into it, it looked like too much work for my time budget at that time.

I don't think Batik would willingly ignore additional fonts made available through -Dsun.awt.fontconfig since this is an AWT facility. If that property makes sure that the fonts are integrated into the AWT font subsystem the fonts should really be available to Batik. But again, maybe the people on batik-users@xmlgraphics.apache.org know more.
Comment 4 M.H. 2008-12-10 03:29:28 UTC
OKay, I opened a new bug for Batik: https://issues.apache.org/bugzilla/show_bug.cgi?id=46374
Comment 5 Cameron McCormack 2009-05-14 18:42:49 UTC
I've committed a small change to Batik that allows non-AWT-toolkit-provided fonts to be embedded in SVG.
Comment 6 Glenn Adams 2012-04-07 01:44:21 UTC
resetting P2 open bugs to P3 pending further review