FOP Arabic letter spacing

799 views Asked by At

I am generating multi-lingual PDF using Apache FOP 2.5, including Latin, Cyrillic and Arabic characters. I managed to include the proper fonts, and I was able to deal with the right-to-left display for Arabic, when needed.

However I am facing an issue with letter-spacing in Arabic characters : the characters are spaced out from each other. This is what I see in the generated PDF

enter image description here

But this is what I have in the original XML (please note how the Arabic characters are close to each other) :

enter image description here

I am using the Deja Vu font and I have computed the metrics of the font using what is described here.

How can I solve this ?

I have read this article which basically inserts letter-spacing="-2pt" everytime the string to be displayed is in Arabic. But I don't want to hardcode tests on the language in the stylesheet.

Any help appreciated !

EDIT :

  • Using FOP 2.5
  • I confirm that complex-script is enabled (added a debug message to be sure)
  • I had set kerning="yes" set in the config file
1

There are 1 answers

0
ThomasFrancart On BEST ANSWER

Thanks to the very valuable comments received, I was able to solve the problem by :

  1. Upgrading to FOP 2.5
  2. Switching to another Font (Traditional Arabic instead of Deja Vu)
  3. And, as FOP 2.5 does not require a font metrics file, removing the font metrics.

In the meanwhile I saw that embedding the fonts in my application was more difficult in FOP 2.5 than in FOP 1.1 because it is harder to set relative URLs in FOP font configuration. I was able to solve this with this other answer.