Table of Contents
More Resources
Creating a Custom fop Configuration

Create a custom fop configuration file to package custom fonts within your plugin.
You created the XML font metric file using the procedure in Creating the XML Font Metric File.

You want to create a custom fop configuration file to allow custom fonts within your plugin.

  1. First, you have to copy the default fop.xconf file from the PDF2 plugin. Copy it from plugins/org.dita.pdf2/fop/conf/fop.xconf to plugins/{plugin_name}/fop/conf/
  2. Locate the < fonts> tag (around line 50).
  3. You should see < auto-detect/> along with a bunch of commented out code.

    Step Information
    Auto-detect means that the DITA Open Toolkit will look for fonts that have been installed on the operating system.

  4. You need to add a line that specifically adds the custom font. Below < auto-detect/> (but before the closing < /fonts> tag), add the following code:

    Step Information
    < font metrics-url="plugins/{plugin_name}/lib/{font_name_xml}" kerning="yes" embed-url="file:plugins/{plugin_name}/lib/{font_name_ttf}"> 
    	< font-triplet name="{font-face_name}" style="{style}" weight="{weight}"/> 
    < /font> 

    {plugin_name} is the name of your plugin folder
    {font_name_xml} is the name of your font’s XML metric file (created in Creating the XML Font Metric File).
    {font_name_ttf} is the name of the .TTF file for your font
    {font-face_name} is the base name of your font. For example, if {font_name_ttf} is Arialuni-Bold.ttf, {font-face_name} would simply be Arialuni.
    {style} can either be “normal” or “italic” based on the .TTF file
    {weight} can either be “normal” or “bold” based on the .TTF file

    Expected Result
    An example for Arialuni-Bold in the com.jorsek.custom.pdf plugin: 

    < font metrics-url="plugins/com.jorsek.custom.pdf/lib/Arialuni-Bold.xml" kerning="yes" embed-url="file:plugins/com.jorsek.custom.pdf/lib/Arialuni-Bold.ttf"> 
    	< font-triplet name="Arialuni" style="normal" weight="bold"/> 
    < /font> 
    Note:If you have multiple fonts (even multiple variants of the same font: bold, italic, etc) you need a separate < font> tag for each one.

  5. Save your custom fop configuration file.
  6. Now, you need to add a parameter to the ant build script to tell the processor where to look for your customized fop configuration file. Open your build template file (build_custom.pdf_template.xml).
  7. Right above the final antcall to dita2pdf, add the following property to your custom target:

    Step Information
    < property name="args.fo.userconfig" value="${dita.dir}/plugins/[plugin_name]/fop/conf/fop.xconf"/> 

You set up your custom fop configuration to include your custom fonts. Next, you’ll need to look at Adding Custom Fonts to the XML.