Unicode drawText "Right to Left" Language issue
Hi Team,
Im trying to drawText on image for "Urdu/Arabic Language" this text "السلام عليكم", text is being drawn on output image but it is being drawn "Left to Right" while it must be "Right to Left" as Arabic/Urdu are "Right to Left" languages. What m i doing wrong? How can I fix it?
gm("/file.png")
.fill('#FF0066')
.drawText(100, -150, "السلام عليكم", 'Center')
.font("/alvi_Nastaleeq.ttf")
.fontSize('38px')
.encoding('Unicode')
Output Image:

http://stackoverflow.com/questions/31753132/unicode-drawtext-right-to-left-language-issue-in-graphicsmagick-for-node
Thanks,
Any suggestion or pointer plz?
What about reversing your text first?
"السلام عليكم".split('').reverse().join('')
I tried reversing and showing, but still dont work. check out this question I updated it for revering text http://stackoverflow.com/questions/31753132/unicode-drawtext-right-to-left-language-issue-in-graphicsmagick-for-node
what does flop do?
Aqib
On Tue, Aug 25, 2015 at 7:44 AM, Dan Rocha [email protected] wrote:
What about using flop? Give a look at the example https://github.com/aheckmann/gm/blob/master/examples/flop.js
— Reply to this email directly or view it on GitHub https://github.com/aheckmann/gm/issues/427#issuecomment-134456966.
Flop mirrors the image horizontally, and not sure what you're trying to achieve, can you create an image with the expected result? With reversing the text the 2nd image in your stackoverflow question should be done
as mentioned in question I m trying to print this text "السلام عليكم" and output result should be same text "السلام عليكم", but output text isn't being printed like that, all I need to achieve is printing Arabic/Urdu text.
How can I do that?
Which is the output when reversing the text? Isn't the desired either?
No, output isn't desired even after reversing, this is reverse text "مكيلع مالسلا" of "السلام عليكم", If I try using reversed text it isn't producing required results as shown in stackoverflow question.
Maybe your problem would be easier to understand if you could provide a desired image, not sure if my browser encoding interferes but I see the reversed text pretty similar to the image you are receiving
My INPUT text is "السلام عليكم" Matching Image:
and Required OUTPUT text must be same as is "السلام عليكم" Matching Image:
Now Issue is output text doesn't matching with input text at all, Current Output text is:
2ndly, If I tried reversing INPUT text as you suggested and used Reversed INPUT text "مكيلع مالسلا" Matching Image:
Still output text is appearing wrong as:
so it doesn't matter if I use reversed string or not, my output results are not desired.
is that helps?
@DanMMX is this question clear to you now?
oh ok, now that you put those images (for everything) is much clearer, I thought it was a matter of font type, now I see it's not. Sorry I don't think I know how to help you, if you come up with a solution let us know
I think its gm support team who can come up with solution, you need to fix the way gm is handling Arabic encoding, fonts and printing.
It's old issue , but I was looking for a solution and I found this module https://github.com/louy/Javascript-Arabic-Reshaper
var ArabicReshaper = require('arabic-reshaper');
var txt = ArabicReshaper.convertArabic('العربية').split("").reverse().join("");
then you can print it correctly with
.drawText(60, 500,txt)
hope someone find this useful .