GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Fop multilanguage support tip Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Fop multilanguage support tip" Watch "Fop multilanguage support tip" New topic

Fop multilanguage support tip

Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
I posted this thread sometime before in fop user group.
Thought this might help someone here.(i forget whether i posted it before)

This thread will give you some tips on supporting
multiple language/fonts in XSL:FO.
1.Create a Language resource XML. Lang.xml
<?xml version="1.0" encoding="UTF-8"?>
<text>Hello World! Cooperate</text>
<text>Hallo Welt!coop�re</text>

2.Locate font.
For english u don't need to find extra fonts unless
u need more style.
For other languages,u need to find either a truetype
or type1 font
For example for Arabic u can use the truetype
(Iqraa.ttf)font downloadble at
Store this in your system say at C:\myfonts\ or
Note:You have to explicitly tell to FOP to use
particular font for rendering other language
datas,otherwise a ? mark appear.

3.Now read the document at docs\html-docs\fonts.html
in your FOP installation carefully.
This document will tell how to add,embedd a new true
type font.
For example: org.apache.fop.fonts.apps.TTFReader
C:\myfonts\Iqraa.ttf Iqraa.xml
b.Change your userconfig.xml file
<font metrics-file="Iqraa.xml" kerning="yes"
<font-triplet name="Iqraa" style="normal"
</font> fop with option -c
4.Now In ur XSL file,try to import particular language
data and store it in a XSL variable
For example the below code will store the fr\text
data in a variable called message.
<xsl:variable name="message"
<xsl:variable name="font"
5.Now use this in fo:block
like this <fo:block

Thats it.
1.With some xsl tricks u can make everything dynamic
without hardcoding any part.
for example arabic font starts at rightend can be
made dynamic by supplying some tags in Lang.xml
Now the question is UNICODE.Use XMLSPY to edit ur
Lang.xml,for example for japanese version of
Hello world go to copy and
paste the japanese word into ur Lang.xml,
XMLSPY will take care of encoding.Sorry for this temp
solution,just to avoid finding each and every unicode
eqvt of other language literals.Any drawbacks?
Please comment if i have made some mistake or hard

Spritle Software Blogs
GeeCON Prague 2014
subject: Fop multilanguage support tip