Right-to-left languages?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
IDtheTarget

Re: Right-to-left languages?

Post by IDtheTarget »

I don't know how it's auto-detected, all I know is that it's quite often that you'll have a mixture of RTL and LTR text in the same string. For instance, in Arabic and Dari, the text is RTL, but the numbers are LTR.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Right-to-left languages?

Post by magick »

The new option is -direction. It will be ready to test in ImageMagick 6.6.1-0 within a day or two:
  • convert -background white -fill black -size 320x320 -encoding Unicode -font AlHor -gravity center \
    -direction right-to-left -pointsize 40 label:'ﺱﻼﻣ' test01.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Right-to-left languages?

Post by anthony »

The font itself should define if the characters are right-to-left according to the how it moves the caret!

The current idea of using -direction would be useless for a sting like... "Hello ﺱﻼﻣ world"...
It seems to me the font rendering library should be handling this, not IM.

One idea as a stop gap measure is to reverse the UTF characters in the string.

Code: Select all

echo -n 'ﺱﻼﻣ' | perl -CIO -pe '$_ = reverse $_;' | convert -font Arial -pointsize 24 label:@- show:

Hey it works!!! Though again it does not handle the mixed direction case.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
IDtheTarget

Re: Right-to-left languages?

Post by IDtheTarget »

I don't know if the font should handle it itself or not. I just know that other programs like Inkscape work.

I tried your reverse one-liner, and while it gets the letters in the correct order, the 'seh' and 'lam-alif' are not connected...

Thanks for the patch, guys!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Right-to-left languages?

Post by anthony »

Don't expect it to remain forever. Cristy is looking for some way of determining the direction of 'words'. However it seems that things like inkscape uses the 'Pango' library to layout words appropriately, and using a layout library is a dependancy that is getting beyond the scope of what IM
does. Remember it is really a raster (array of pixels) image processor, not a layout and text processor.

Now their are also other alternatives. for example using postscript of as we saw above SVG for the handling of more complex layout handling. these use an external delegate library to do the task producing a raster image for IM to continue its processing with.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Keld_von_Eyben
Posts: 5
Joined: 2010-04-21T02:08:15-07:00
Authentication code: 8675308

Re: Right-to-left languages?

Post by Keld_von_Eyben »

The new option -direction is extremely interesting as we use IM to generate open captions/subtitles for film production (we routinely subtitle in Chinese, Japanese and all European languages)
The script below works fine - but IM seems to ignore the -direction option when texts are rendered using -annotate or -draw text.
Should the -direction option work in connection with the -annotate command?
And should the -direction option work with the -draw text command?
Please confirm this - and thank you again for a great concept!

Best regards
Keld
http://www.filmsolutions.dk
magick wrote:The new option is -direction. It will be ready to test in ImageMagick 6.6.1-0 within a day or two:
  • convert -background white -fill black -size 320x320 -encoding Unicode -font AlHor -gravity center \
    -direction right-to-left -pointsize 40 label:'ﺱﻼﻣ' test01.png
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Right-to-left languages?

Post by magick »

The -direction option should apply to -annotate and -draw options. We'll need a few days to investigate the problem and we will report back here.
Keld_von_Eyben
Posts: 5
Joined: 2010-04-21T02:08:15-07:00
Authentication code: 8675308

Re: Right-to-left languages?

Post by Keld_von_Eyben »

Great! Thank you!
Maybe I should add that I am using MS Access database running VisualBasic to access IM through its COM interface on Windows XP platform.

Keld
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Right-to-left languages?

Post by magick »

We have a patch so that the -direction option works with the -annotate and -draw options. Look for it in ImageMagick 6.6.1-5 Beta available by sometime tomorrow.
Keld_von_Eyben
Posts: 5
Joined: 2010-04-21T02:08:15-07:00
Authentication code: 8675308

Re: Right-to-left languages?

Post by Keld_von_Eyben »

Fantastic! :D

Best regards
Keld
Keld_von_Eyben
Posts: 5
Joined: 2010-04-21T02:08:15-07:00
Authentication code: 8675308

Re: Right-to-left languages?

Post by Keld_von_Eyben »

I'm trying to implement the new -direction in IM 6.6.1-6 2010-04-23 Q16
Are you sure it will work when using

Code: Select all

-annotate '@utf8textfile.txt' 
?
Using UTF8 textfiles is the only way I can send Arabic text to IM in a Windows environment.

Thank you for your support!
myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Re: Right-to-left languages?

Post by myicq »

This is an old topic, but could not find anyone that discussed it since.

My need is to take a text file and line-by-line create a graphic 300px high with that line.
ImageMagick is perfect for the job, except it still does not handle unicode correct.

I have ImageMagick 6.7.6-5 4.4.2012

Input file tried both UTF8, UTF16 with /without BOM. Same result: when mixing left to right (English) with right to left (Hebrew / Arab..), the RTL is written backwards (as in left-to-right).

InkScape does the conversion as expected, but I would prefer to use IM as I can script this in a more convenient way, and less disc space is needed.

As an example, I have used the text:
Hello, ישראל out there (إسرائيل)
As you can see, the -direction is no good since it simply reverses everything.


Example of InkScape file which works:

Code: Select all

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="3500px" height="300px" viewBox="0 0 3500 300"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
  <desc>Example text01</desc>
  <text x="20" y="240" 
        font-family="Arial" font-size="250" fill="black" >
    Hello, ישראל out there (إسرائيل)
  </text>
</svg>
Thanks for any input on this topic.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Right-to-left languages?

Post by anthony »

The new "pango:" coder supports right to left text handling -- automatically.

Code: Select all

convert -pointsize 36 pango:"Hello, ישראל out there (إسرائيل)" show:
I confirmed that it reverses the sequence of characters, compared to that of label: (without a -direction setting).

See IM Examples, Pango Text Formatting
http://www.imagemagick.org/Usage/text/#pango

NOTE pango also automatically does font changes as need to allow bold, and italic text, when the pango markup requests it.


ASIDE: pango with the latest IM is part of the latest updates in CYGWin for windows users.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Re: Right-to-left languages?

Post by myicq »

The new "pango:" coder supports right to left text handling -- automatically.
This is very interesting !

Is there any information available (examples, how-tos, tutorials) anywhere about using pango with Perl + Windows ? Or other scripting languages under Windows ?

Unfortunately, for other reasons, I need to have the output from IM / Pango in a Windows platform

Any help appreciated.

Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Right-to-left languages?

Post by anthony »

I am not a windows user, but it was reported that it is in the latest Cygwin Command line package (which provides UNIX shells under windows environment)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply