1

Am I correct that it's not possible to use fonts from windows 7 c:\windows\fonts* when using XSL-FO (Apache FOP) to generate a pdf?

I've just installed the "helvetica neue" font in OTF format.

According to https://xmlgraphics.apache.org/fop/trunk/fonts.html

"Support for system fonts relies on the Java AWT subsystem for font metric information. Through operating system registration, the AWT subsystem knows what fonts are available on the system, and the font metrics for each one.

When working with renderers that supports system fonts (see above table) and you're missing a font, you can just install it in your operating system and it should be available for these renderers. Please note that this is not true for output formats, such as PDF or PostScript, that only support custom fonts."

If my understanding is correct, it's saying that if my render is PDF (meaning output is pdf??), then I can't access the fonts through AWT/OS, therefore, I won't be able to generate the text with such fonts in PDF using the the windows 7 fonts?

------------------------------Update, this works only for ttf font, not otf. Not sure how I can get otf fonts to work.

-----------------------------update: 20150402:

Using FOP 1.1:

I downloaded this particular free helvetica neue font from: http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html

I configured fop to use fop.xconf but I'm getting an error processing the ttf file, and I don't know how to edit the font ttf file with fontforge:

fop -c fop.xconf -xml xml.xml -xsl coversheet.xsl -pdf output.pdf

Apr 2, 2015 6:53:55 PM org.apache.fop.fonts.truetype.TTFFile readCMAP
SEVERE: Unsupported TrueType font: No Unicode or Symbol cmap table not    present. Aborting
Apr 2, 2015 6:53:55 PM org.apache.fop.events.LoggingEventListener    processEvent
WARNING: Unable to load font file: file:/C:/windows/FONTS/HelveticaNeue.ttf. Reason: java.io.IOException: TrueType font is not supported: file:/C:/windows/FONTS/HelveticaNeue.ttf

Apr 2, 2015 6:53:55 PM org.apache.fop.fonts.truetype.TTFFile getTTCnames
INFO: This is a TrueType collection file with 4 fonts

Thanks

Derick
  • 85
  • 3
  • 12
  • Did you try already? But I'd say your interpretation is correct, there is no way to access system fonts when rendering PDF. But you could still register Helvetica Neue as a custom font in FOP config. – Mathias Müller Mar 31 '15 at 22:04
  • I tried it and was able to insert fonts that are of ttf format, but I can't output otf font files. I think that documentation is out of date. – Derick Mar 31 '15 at 23:37
  • Then why not convert the OTF font to TTF and then use it as a custom font? – Mathias Müller Apr 01 '15 at 08:51
  • I checked the font you are using, and unfortunately even FOP trunk gives an error similar to the one you are mentioning: `The font does not have a Unicode cmap table`. I tested FOP trunk with the [source sans pro](https://github.com/adobe-fonts/source-sans-pro) otf fonts, and everything worked, so the font you are using probably has some still unsupported characteristics. – lfurini Apr 03 '15 at 07:07

1 Answers1

0

(preliminary disclosure: I'm a FOP developer)

Am I correct that it's not possible to use fonts from windows 7 c:\windows\fonts* when using XSL-FO (Apache FOP) to generate a pdf?

Fonts need to be configured in order to be recognised and used by FOP, but the configuration can be really simple: you can tell FOP to look at all the font files in a specific directory (even recursively), or simply to look for font in the "usual" places.

This configuration fragment is taken from the same font configuration page linked in your question:

<renderers>
  <renderer mime="application/pdf">
     <fonts>
        <!-- register all the fonts found in a directory -->
        <directory>C:\MyFonts1</directory>

        <!-- register all the fonts found in a directory and all of its sub directories (use with care) -->
        <directory recursive="true">C:\MyFonts2</directory>

        <!-- automatically detect operating system installed fonts -->
        <auto-detect/>
     </fonts>
  </renderer>
</renderers>

You can find additional details concerning the font configuration in this answer.

Update, this works only for ttf font, not otf. Not sure how I can get otf fonts to work.

OpenType fonts support has been added with version 2.0.

Community
  • 1
  • 1
lfurini
  • 3,420
  • 4
  • 27
  • 40
  • downloaded www.ephifonts.com/free-helvetica-font-helvetica-neue.html but I'm getting an error: org.apache.fop.fonts.truetype.TTFFile readCMAP SEVERE: Unsupported TrueType font: No Unicode or Symbol cmap table not present. Aborting org.apache.fop.events.LoggingEventListener processEvent WARNING: Unable to load font file: file:/C:/windows/FONTS/HelveticaNeue.ttf. Reason: java.io.IOException: TrueType font is not supported: file:/C:/windows/FONTS/HelveticaNeue.ttf org.apache.fop.fonts.truetype.TTFFile getTTCnames See my update above. Don't know how to use font forge to edit – Derick Apr 03 '15 at 02:06
  • The free helvetica neue font is from http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html but apparently, it does'nt work with fop 1.1 – Derick Apr 03 '15 at 02:21
  • lfurini, i just want to confirm with you, when you say "OTF support has been added after the release of FOP-1.1" this means that fop 1.1 will support otf right, regardless if I get the nightly build. I downloaded the last stable release. – Derick Apr 03 '15 at 02:28
  • Sorry @Derick, my answer was not very clear: OTF support is not available in the stable releases, as it was implemented recently and there haven't been a new release including it yet. You can use it if you download a [snapshot build](http://ci.apache.org/projects/xmlgraphics/fop/snapshots/#snapshots) (already compiled, based on the latest code). Answer updated – lfurini Apr 03 '15 at 06:40
  • 1
    OTF support is available in the recently released Apache FOP 2.0: https://xmlgraphics.apache.org/fop/2.0/releaseNotes_2.0.html – IvoC Jun 04 '15 at 15:56