Hi,
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
example
<?xml version="1.0" encoding="UTF-8"?>
<Lang>
<en>
<text>Hello World! Cooperate</text>
<fontname>Courier</fontname>
</en>
<fr>
<text>Hallo Welt!coop�re</text>
<fontname>FrenchTTF</fontname>
</fr>
<jp/>
<ch/>
</Lang>
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
http://www7.bev.net/civic/icb/ICB_Arabic.html Store this in your system say at C:\myfonts\ or
somewhere.
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:
a.java 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"
embed-file="C:\myfonts\Iqraa.ttf">
<font-triplet name="Iqraa" style="normal"
weight="normal">
</font>
c.run 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"
select="document('Lang.xml')/Lang/fr/text"/>
<xsl:variable name="font"
select="document('Lang.xml')/Lang/fr/fontname"/>
5.Now use this in fo:block
like this <fo:block
font-family="{$font}"><xsl:value-of
select="$message"/></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
http://www.babylon.com/ 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
code.
Regards
balaji