Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Fop multilanguage support tip  RSS feed

Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
James fork
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the details.
Could you please provide an example working code.

Thanks In Advance
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!