To support Japanese content, you must configure DITA Open
Toolkit to use fonts that generate Japanese characters. You must select
the desired font and integrate it with the DITA Open Toolkit.
About this task
Note: The following configuration steps are based
on DITA Open Toolkit 1.4.3 that uses the FOP plug-in for PDF.
Procedure
The following example shows the procedure to add the
MS Gothic True Type font. However, you can replace MS Gothic True
Type with the font that best suits your needs.
- Modify DITA_HOME\demo\fo\build.xml to
support Japanese characters:
Change from:
<property name="document.locale" value="en_US" />
To:
<property name="document.locale" value="ja_JP" />
- Generate a font metrics XML file from the True Type font
that you will use. The following example uses msgothic.ttc to
generate a font metrics file msgothic.xml under
the fonts directory:
cd DITA_HOME\demo\fo\fop
mkdir fonts
java -cp build\fop.jar;lib\avalon-framework-4.2.0.jar;lib\commons-logging-1.0.4.jar;lib\commons-io-1.3.1.jar;lib\xmlgraphics-commons-1.3.1.jar org.apache.fop.fonts.apps.TTFReader -ttcname "MS Gothic" C:\WINDOWS\Fonts\msgothic.ttc fonts\msgothic.xml
Because msgothic.ttc is
a True Type Collection, use the -ttcname option to specify which font
in the collection you are using.
- Modify the font metrics file generated by the previous
step. Replace existing values for font-name, full-name and family-name
with MSGothic.
Remember: Do not change the
value of the ttc-name element.
- Modify DITA_HOME\fo\fop\conf\fop.xconf and
add the following XML (replace hard-coded paths as needed). The XML
must be placed within the <fonts></fonts> tags.
<fonts>
:
<font metrics-url="file:///C:/sccs/DITA-OT1.4.3/demo/fo/fop/fonts/msgothic.xml" embed-url="file:///C:/WINDOWS/Fonts/msgothic.ttc" kerning="yes">
<font-triplet name="MSGothic" style="normal" weight="normal"/>
<font-triplet name="MSGothic" style="normal" weight="bold"/>
<font-triplet name="MSGothic" style="italic" weight="normal"/>
<font-triplet name="MSGothic" style="italic" weight="bold"/>
</font>
- Customize the fonts and globalization of FO output under
the Customization directory. First, copy the system font-mappings.xml file
to the customization directory.
cd DITA_HOME\demo\fo\Customization
copy ..\cfg\fo\font-mappings.xml .\fo\
Open fo\font-mappings.xml and
modify all references to char-set Japanese such that the font-face
value is MSGothic
<physical-font char-set="Japanese">
<font-face>MSGothic</font-face>
</physical-font>
- Modify fo\i18n\ja_JP.xml to include
the character range of your selected font.
cd DITA_HOME\demo\fo\Customization
copy ..\cfg\fo\i18n\ja_JP.xml .\fo\i18n\
Open
fo\i18N\ja_JP.xml to
expand the character range for non-kanji characters.
<alphabet char-set="Japanese">
<character-set>
:
<character-range>
<start include="yes">Ⅰ</start>
<end include="yes">↯</end>
</character-range>
<character-range>
<start include="yes">①</start>
<end include="yes">⓯</end>
</character-range>
<character-range>
<start include="yes">＀</start>
<end include="yes">￯</end>
</character-range>
<!-- DOUBLE VERTICAL LINE / PARALLEL TO -->
<character>∥</character>
</character-set>
</alphabet>
- Enable the customization code:
cd DITA_HOME\demo\fo\Customization
copy catalog.xml.orig catalog.xml
- Open the catalog.xml file and uncomment
the following two lines for font mappings and Japanese globalization.
<uri name="cfg:fo/font-mappings.xml" uri="fo/font-mappings.xml"/>
<uri name="cfg:fo/i18n/ja_JP.xml" uri="fo/i18n/ja_JP.xml"/>
Results
The DITA Open Toolkit is now configured to support the
MSGothic Japanese character font.