Table of Contents
More Resources
Creating the XML Font Metric File

Create the XML font metric file to compile a font with your plugin.
prereq
You built a plugin and installed a font locally on your computer using the procedures in Installing Custom Fonts and Finding Font Names.

context
You want to create the XML font metrics file to compile the fonts with your plugin to use in easyDITA.

  1. Open the DITA Open Toolkit in the Command Line.
  2. We need to create the file that will generate the metric file. If you have already created this file, you just need to update the last line to point to the new font. This file should be saved in your root DITA OT directory.

    1. For OS X and Linux create a text file called “ttfConvert.sh” with the following contents:

      Step Information
      #!/bin/sh 
      
      export LIB=plugins/org.dita.pdf2/fop/lib
      export CP=plugins/org.dita.pdf2/fop/build/fop.jar
      export CP=$CP:$LIB/avalon-framework-4.2.0.jar
      export CP=$CP:$LIB/xercesImpl-2.7.1.jar
      export CP=$CP:$LIB/commons-logging-1.0.4.jar
      export CP=$CP:$LIB/commons-io-1.3.1.jar
      export CP=$CP:$LIB/xmlgraphics-commons-1.5.jar
      export CP=$CP:$LIB/xml-apis-1.3.04.jar
      export CMD="java -cp $CP org.apache.fop.fonts.apps.TTFReader"
      
      $CMD {path_to_font}{font_name}.xml

      You should set the {path_to_font} variable to be the path to the .TTF font file locally on your computer. For example: /Users/slucchini/Library/Fonts/Arialuni.ttf
      Then fill in the {font_name} with the name of the font. For example: Arialuni

    2. For Windows create a text file called “ttfConvert.bat” with the following contents:

      Step Information
      @echo off
      set LIB=plugins\org.dita.pdf2\fop\lib
      set CP=plugins\org.dita.pdf2\fop\build\fop.jar
      set CP=%CP%;%LIB%\avalon-framework-4.2.0.jar
      set CP=%CP%;%LIB%\xercesImpl-2.7.1.jar
      set CP=%CP%;%LIB%\commons-logging-1.0.4.jar
      set CP=%CP%;%LIB%\commons-io-1.3.1.jar
      set CP=%CP%;%LIB%\xmlgraphics-commons-1.5.jar
      set CP=%CP%;%LIB%\xml-apis-1.3.04.jar
      set CMD=java -cp "%CP%" org.apache.fop.fonts.apps.TTFReader
      
      %CMD% {path_to_font}{font_name}.xml

      You should set the {path_to_font} variable to be the path to the .TTF font file locally on your computer. For example: C:\Windows\Fonts\Arialuni.ttf
      Then fill in the {font_name} with the name of the font. For example: Arialuni

    3. If you want to convert multiple fonts at once (for example, if a font has a bold and/or italic variant), you can just copy the last line in the script and paste it again below with a different font path and name.
  3. In the DITA Open Toolkit command line that you opened in Step 1, run the file you just created using one of the two commands below. And you should be in the root directory of the toolkit (where you saved the script in Step 2).

    Step Information
    For OS X and Linux:

    sh ttfConvert.sh
    For Windows:

    ttfConvert.bat
    Important:If you get an error look in the plugins/org.dita.pdf2/fop/lib folder, check that each of the .jar files are there. Your version of the DITA Open Toolkit may have different versions of some of the files (commons-logging-1.1.1.jar instead of commons-logging.1.0.4).

  4. You should now see the XML metric files in the root folder of the DITA Open Toolkit. You’ll need to move these into your custom plugin.

    Expected Result
    {plugin_name}/lib/Arialuni.xml

  5. Create a folder named “lib” in the root of your plugin directory.

    Step Information
    plugins/{plugin_name}/lib/

  6. Move the XML font metric files and the original .TTF font file that you used to create the XML font metric (the {path_to_font} from Step 2) into the lib folder.
result
You created the XML font metrics files for your fonts. See Creating a Custom fop Configuration to create a customized fop configuration file to allow custom fonts within your plugin.