Unicode drawText "Right to Left" Language issue in GraphicsMagick for node

Im using GraphicsMagick for the node and trying to draw text in “Urdu / Arabic Language” for that text “السلام عليكم”, the text is drawn in the output image, but it is drawn “left to right” while it should be “right to left”, since Arabic / Urdu are right-to-left languages.

gm("/file.png") .fill('#FF0066') .drawText(100, -150, "السلام عليكم", 'Center') .font("/alvi_Nastaleeq.ttf") .fontSize('38px') .encoding('Unicode') 

Output Image:

enter image description here

If Im trying to use the inverse urdu "مكيلع مالسلا", even if the text is not drawn correctly.

enter image description here

What am I doing wrong? How can i fix this?

Thanks,

+4
source share
1 answer

I'm looking for the same thing and I found that
you need to enable the text_shaping parameter
you need to configure FFmpeg with - enable-libfribidi
read about text_shaping here
https://ffmpeg.org/ffmpeg-filters.html#Syntax
I have not tested it, but I will, when I get the result, I will post the code here
I want me to show you here the working code that I use to create such videos enter image description here

 ffmpeg -y -loop 1 -framerate 25 -i bachground-img.jpg -vf "drawtext=text_shaping=1:fontfile=C\/:/Windows/Fonts/tradbdo.ttf:\ textfile=text-new.txt:fontcolor=white:fontsize=75:x=(w-tw)/2:y=h-25*t:" -t 45 -pix_fmt yuv420p output.mp4 
+2
source

All Articles