adding fonts for FOP processing?

Skip to first unread message

Alan Houser

Mar 10, 2021, 9:47:32 AMMar 10
to DITA-OT Users

I've specified custom fonts for a couple of FOP-based PDF transforms (custom plugin > org.dita.pdf2 > org.dita.pdf2.fop). I specify the new fonts in org.dita.pdf2.fop/cfg/fop.xconf.

This means that I can't simply hand off my custom plugin. The client/customer also needs to update org.dita.pdf2.fop. This is "fine", but I would prefer that all of my customizations remain in the custom plugin. It's too easy to neglect to update org.dita.pdf2.fop when migrating to a new version of the OT.

I don't see an obvious way to reference my modified fop.xconf elsewhere. Am I missing an alternative approach?


-Alan Houser

Michael Morrison

Mar 11, 2021, 1:59:28 PMMar 11
to DITA-OT Users
I also developed a custom plugin for PDF generation, based on the DOT PDF2 plugin.  And my PDFs require a few custom fonts, and for initial development, I used FOP (the production version uses XEP).  However, I never touched any of the files inside the org.dita.pdf2 folder; I made all of my changes inside files in my com.xxxx.pdf/cfg/fo folders.

When I needed to specify a new font, I added a specification for it to one of my "attr" files.  For example, commons-attr.xsl includes the following attribute set:

    <xsl:attribute-set name="__fo__root" use-attribute-sets="base-font">
        <xsl:attribute name="font-family">Arial, MyriadPro-Regular, Tahoma, sans-serif</xsl:attribute>
        <xsl:attribute name="xml:lang" select="translate($locale, '_', '-')"/>
        <xsl:attribute name="writing-mode" select="$writing-mode"/>
The custom font is "MyriadPro-Regular".  To ensure that this font is called by FOP during PDF processing, I added the appropriate .ttf and .otf files to my C:\Windows\Fonts folder (my plugin never used FOP on Linux, so I'm not sure where to store the fonts there; for XEP, I stored them to the appropriate /xep/fonts/ directory).

So, when you deliver your custom plugin, your installer should copy the plugin files to the DITA-OT/plugins folder, copy the font files to the appropriate OS folder, and then perform the dita --install command.

Hope that helps.
Reply all
Reply to author
0 new messages