Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Im using GraphicsMagick for node and 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.

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 using reverse urdu "مكيلع مالسلا" string even then text isn't being drawn correctly.

enter image description here

What m i doing wrong? How can I fix it?

Thanks,

like image 558
Aqib Mumtaz Avatar asked Sep 28 '22 03:09

Aqib Mumtaz


1 Answers

i'm searching for the same thing and i found that
you need to enable the text_shaping option
you need to configure FFmpeg with --enable-libfribidi
read about text_shaping here
https://ffmpeg.org/ffmpeg-filters.html#Syntax
i didn't test it but i will, when i get a result i will post the code here
i wish i have pointed you out here's a working code i use to produce videos like this 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
like image 192
Abdalla Mohamed Aly Ibrahim Avatar answered Oct 01 '22 06:10

Abdalla Mohamed Aly Ibrahim