GD Library (Perl and PHP graphics) and Persian support problem

110 views
Skip to first unread message

Afshar Mohebbi

unread,
Apr 21, 2009, 8:09:18 AM4/21/09
to Persian Computing
Hi everybody,

Does anybody here have had any experience with Perl or PHP graphic
with displaying Persian text on them? Both of them use GD Library as
graphic engine.
I'm trying to localize OTRS and have some problems while generating
graphical (and text CSV) reports. It does not show Persian characters
correctly, it shows just European characters with accent above. I have
prepared a picture of it and a full history of problem in a blog post
in my weblog at:
http://afsharm.blogspot.com/2009/04/otrs-gd-library-and-persian-support.html

Please help me get rid of this nightmare!

Regards
Afshar Mohebbi

Behnam Esfahbod ZWNJ

unread,
Apr 21, 2009, 8:30:48 AM4/21/09
to Afshar Mohebbi, Persian Computing
Hi Afshar,

You should use FriBidi's [1] log2vis() function and get the visual
representation of the text before passing it to GD's renderer
function.

For PHP, PECL has a fribidi port, which you can use. [2] Note that if
the version of fribidi is 0.10 (or older), you will have to apply the
arabic-shaping algorithm after that. If you use fribidi 0.19 (or
newer), there's no need for a separate shaping procedure.

You can find more on this issue on the old P-C archive [3].


-Behnam ZWNJ

[1] http://fribidi.org/
[2] http://pecl.php.net/package/fribidi
[3] http://gmane.org/info.php?group=gmane.comp.misc.persiancomputing
--
' بهنام اسفهبد
' Behnam Esfahbod
'
* .. http://behnam.esfahbod.info
* ` *
* o * http://zwnj.org

Saman Barghi

unread,
Apr 21, 2009, 11:39:21 AM4/21/09
to Behnam Esfahbod ZWNJ, Afshar Mohebbi, Persian Computing
Hi,
FriBidi is defenitely the solution to your problem. However, I saw that you refered to BerliOS PHP implementation[1], and you mentioned that it was not working. As I had the same problem, and since I did not have access to the webserver and could not compile PHP with FriBidi I used their implementation[2] to run my website[3]. I also found another PHP implementation [4], however  BerliOS worked for me.

One of the problems might be the font that you are using. Not all the fonts are compatible with these implementations, so you should select your font carefully. Thulmaz e.g. was a good choice for me as I wanted to visualize persian poems, it had the look and was wroking with all three implementations.  There are also some fonts included in [2] and [4] which you can use, and you should be careful about persian and arabic  letters e.g. ی. 

Does anyone know any other fonts ?


Best Regards,
Saman Barghi


[1] http://developer.berlios.de/projects/persian-log2vis/
[2] http://persiangd.berlios.de/doku.php
[3] http://sher-negar.info
[4] http://www.phpclasses.org/browse/package/2132.html

Behdad Esfahbod

unread,
Apr 21, 2009, 2:57:54 PM4/21/09
to Saman Barghi, Behnam Esfahbod ZWNJ, Afshar Mohebbi, Persian Computing
On 04/21/2009 11:39 AM, Saman Barghi wrote:
> Does anyone know any other fonts ?

Thanks Saman for the summary.

All FarsiWeb fonts [5] should work.

Cheers,
behdad

[5] http://www.farsiweb.ir/wiki/Persian_fonts

Saman Barghi

unread,
Apr 21, 2009, 4:04:06 PM4/21/09
to Behdad Esfahbod, Behnam Esfahbod ZWNJ, Afshar Mohebbi, Persian Computing
Thanks Behdad, yeah sure, I just forget about them. They work, but there is a problem with "ه". Check the website (http://sher-negar.info). Do you have any clue ?


Regards,
Saman

Behdad Esfahbod

unread,
Apr 21, 2009, 4:07:50 PM4/21/09
to Saman Barghi, Behnam Esfahbod ZWNJ, Afshar Mohebbi, Persian Computing
On 04/21/2009 04:04 PM, Saman Barghi wrote:
> Thanks Behdad, yeah sure, I just forget about them. They work, but there
> is a problem with "ه". Check the website (http://sher-negar.info). Do
> you have any clue ?

Can't tell without seeing the source. I'm guessing that the code you use does
no substitution for the isolated case. That's a wrong assumption.

Are you using FriBidi? Don't remember what you ended up using.

behdad

> Regards,
> Saman
>
> On Tue, Apr 21, 2009 at 2:57 PM, Behdad Esfahbod <beh...@behdad.org
> <mailto:beh...@behdad.org>> wrote:
>
> On 04/21/2009 11:39 AM, Saman Barghi wrote:
>
> Does anyone know any other fonts ?
>
>
> Thanks Saman for the summary.
>
> All FarsiWeb fonts [5] should work.
>
> Cheers,
> behdad
>
> [5] http://www.farsiweb.ir/wiki/Persian_fonts
>
>
>
> Best Regards,
> Saman Barghi
>
>
> [1] http://developer.berlios.de/projects/persian-log2vis/
> [2] http://persiangd.berlios.de/doku.php
> [3] http://sher-negar.info
> [4] http://www.phpclasses.org/browse/package/2132.html
>
>
>
> On Tue, Apr 21, 2009 at 8:30 AM, Behnam Esfahbod ZWNJ
> <beh...@zwnj.org <mailto:beh...@zwnj.org>
> <mailto:beh...@zwnj.org <mailto:beh...@zwnj.org>>> wrote:
>
>
> Hi Afshar,
>
> You should use FriBidi's [1] log2vis() function and get the
> visual
> representation of the text before passing it to GD's renderer
> function.
>
> For PHP, PECL has a fribidi port, which you can use. [2]
> Note that if
> the version of fribidi is 0.10 (or older), you will have to
> apply the
> arabic-shaping algorithm after that. If you use fribidi
> 0.19 (or
> newer), there's no need for a separate shaping procedure.
>
> You can find more on this issue on the old P-C archive [3].
>
>
> -Behnam ZWNJ
>
> [1] http://fribidi.org/
> [2] http://pecl.php.net/package/fribidi
> [3]
> http://gmane.org/info.php?group=gmane.comp.misc.persiancomputing
>
>
> On Tue, Apr 21, 2009 at 4:39 PM, Afshar Mohebbi
> <afshar....@gmail.com <mailto:afshar....@gmail.com>
> <mailto:afshar....@gmail.com

Saman Barghi

unread,
Apr 21, 2009, 5:06:00 PM4/21/09
to Behdad Esfahbod, Behnam Esfahbod ZWNJ, Afshar Mohebbi, Persian Computing
You are right, there should be something wrong with the implementation. I am using the berlios implementation. I'll try to figure it out later and post the solution if I found one.


Saman

Behdad Esfahbod

unread,
Apr 21, 2009, 10:42:01 PM4/21/09
to Saman Barghi, Behnam Esfahbod ZWNJ, Afshar Mohebbi, Persian Computing, Roozbeh Pournader
Humm, I checked the code and the font, and I can't see why that should happen.

CC'ing Roozbeh. Roozbeh, remember gecko had problems with some of FarsiWeb
fonts, using the wrong Heh? What was the bug, do you remember?

Cheers,
behdad

On 04/21/2009 05:06 PM, Saman Barghi wrote:
> You are right, there should be something wrong with the implementation.
> I am using the berlios implementation. I'll try to figure it out later
> and post the solution if I found one.
>
>
> Saman
>
> On Tue, Apr 21, 2009 at 4:07 PM, Behdad Esfahbod <beh...@behdad.org
> <mailto:beh...@behdad.org>> wrote:
>
> On 04/21/2009 04:04 PM, Saman Barghi wrote:
>
> Thanks Behdad, yeah sure, I just forget about them. They work,
> but there
> is a problem with "ه". Check the website
> (http://sher-negar.info). Do
> you have any clue ?
>
>
> Can't tell without seeing the source. I'm guessing that the code
> you use does no substitution for the isolated case. That's a wrong
> assumption.
>
> Are you using FriBidi? Don't remember what you ended up using.
>
> behdad
>
> Regards,
> Saman
>
> On Tue, Apr 21, 2009 at 2:57 PM, Behdad Esfahbod
> <beh...@behdad.org <mailto:beh...@behdad.org>

Beh

unread,
Apr 21, 2009, 10:54:18 PM4/21/09
to Persian Computing
Try one of these fonts. If you encountered the same problem, I like to
know what this is all about!
http://wiki.irmug.org/index.php/X_Series_2#Download_fonts

> >         <afshar.mohe...@gmail.com <mailto:afshar.mohe...@gmail.com>
> >         <mailto:afshar.mohe...@gmail.com <mailto:afshar.mohe...@gmail.com>>
> >         <mailto:afshar.mohe...@gmail.com <mailto:afshar.mohe...@gmail.com>
> >         <mailto:afshar.mohe...@gmail.com


> >         <mailto:afshar.mohe...@gmail.com>>>> wrote:
>
> >          > Hi everybody,
>
> >          > Does anybody here have had any experience with Perl or PHP
> >                 graphic
> >          > with displaying Persian text on them? Both of them use GD
> >                 Library as
> >          > graphic engine.
> >          > I'm trying to localize OTRS and have some problems while
> >                 generating
> >          > graphical (and text CSV) reports. It does not show Persian
> >                 characters
> >          > correctly, it shows just European characters with accent above. I
> >                     have
> >          > prepared a picture of it and a full history of problem in a
> >                 blog post
> >          > in my weblog at:
>

> >        http://afsharm.blogspot.com/2009/04/otrs-gd-library-and-persian-suppo...


>
> >          > Please help me get rid of this nightmare!
>
> >          > Regards
> >          > Afshar Mohebbi
>
> >                     --
> >         '     بهنام اسفهبد
> >         '     Behnam Esfahbod
> >         '

> >                       *  ..http://behnam.esfahbod.info

Saman Barghi

unread,
Apr 22, 2009, 12:03:45 AM4/22/09
to Beh, Persian Computing
Dear Behnam,
I tried them and they worked flawlessly; the problem exists only for FariWeb fonts.


Best Regards,
Saman

Afshar Mohebbi

unread,
Apr 22, 2009, 1:39:16 AM4/22/09
to Persian Computing
Dear all friends,

Many thanks to your kind replies, but seems FriBiDi is going to target
Unicode Annex 9 and my problem is not UA9 (yet). I'm seeing question
marks and in some cases European characters instead of my Persian
text! I'm in a step before Annex#9!
For more info plz see following pictures:

Eurpean characters instead of Persian text (generated by OTRS)
http://lh3.ggpht.com/_NHQs4ySP7wI/Se21FEThm0I/AAAAAAAAAME/a62dsX2pN_0/image9.png

Question marks instead of Persian characters (generated by GD Sharp,
a .Net wrapper for GD Library)
http://i39.tinypic.com/wt7uk9.png


Cheers
Afshar Mohebbi
Reply all
Reply to author
Forward
0 new messages