Page 1 of 1

possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-03T09:48:20-07:00
by fmw42
IM 6.7.0.2 Q16 Mac OSX TIGER.

The following fails, assuming I understand what -direction right-to-left is supposed to do.

convert -background lightblue -fill blue -pointsize 48 -font Arial -direction right-to-left label:"ABCDEFG" tmp.png

The resulting image is only the letter A.


see also viewtopic.php?f=3&t=18868

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-03T10:20:53-07:00
by magick
We'll get a patch into ImageMagick 6.7.0-4 Beta by sometime tomorrow to fix the problem you reported.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-05T06:06:36-07:00
by teebe
magick:
results are not good, besides direction is correct. I use Microsoft Visual Studio 2008 Version 9.0.30729.1, it compiles with no errors or warnings but i have a broken convert.exe output, both in terms of render and characters, as (in arabic) it superimposes some.

Thank you

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-06T10:46:13-07:00
by fmw42
IM 6.7.0.4 Mac OSX Tiger

The command

convert -background lightblue -fill blue -pointsize 48 -font Arial -direction right-to-left label:"ABCDEFG" A2G_reversed.png

Image

does indeed now reverse the characters, BUT they are not filled.

Likewise without the -direction, they are still not filled.

convert -background lightblue -fill blue -pointsize 48 -font Arial label:"ABCDEFG" A2G.png

Image

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-06T23:17:05-07:00
by teebe
Hi, the output of convert.exe with -direction right-to-left shows double strokes (or advance skipping):
Image
as well a weird rendering.
It would be nice to get to the end, i could use IM for a new project.
Cheers

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-07T10:30:27-07:00
by magick
Try ImageMagick 6.7.0-5. It will be a day or two until we get updated versions of the Windows binaries for this release.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-07T12:25:40-07:00
by fmw42
IM 6.7.0.5 Q16 Mac OSX Tiger.

This command seems to be working nearly correctly now, but the G seems a bit too close to the F. Is that the way it will be?

convert -background lightblue -fill blue -pointsize 48 -font Arial -direction right-to-left label:"ABCDEFG" A2G_reversed2.png

Image

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-07T18:46:42-07:00
by magick
We just write the characters from right to left and use the font metrics to decide where to place each character. A couple of solutions would be to 1) reverse the string and place the letters left to right; 2) use a proper text layout manager such as Pango; or 3) ImageMagick could reverse the string and then place the characters left to right.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-07T18:51:53-07:00
by fmw42
magick wrote:We just write the characters from right to left and use the font metrics to decide where to place each character. A couple of solutions would be to 1) reverse the string and place the letters left to right; 2) use a proper text layout manager such as Pango; or 3) ImageMagick could reverse the string and then place the characters left to right.
For me this was only a simple test case to help you and that other person with the arabic characters. So if it works out for the arabic characters, then I am not overly concerned. If I had to do it for English from your suggestions, I would probably try your option 3)

Thanks.

Fred

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-07T19:02:02-07:00
by magick
The advance metric is determined by looking at two side-by-side characters. For right-to-left we need to look at the next character rather than the last. We'll add a patch to ImageMagick within a day or two.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-08T07:56:24-07:00
by teebe
IM 6.7.0-5 makes better rendering but -direction right-to-left is always broke.
Screen shots and process output:
1 - Screen grab of original strings (OUTLOOK MAIL):
Image
2 - IM 6.7.0-5 No RTL, no pre-invertion:
Image
3 - IM 6.7.0-5 with -direction RTL:
Image
4 - IM 6.7.0-5 No RTL but pre-inverted by friend code:
Image
Images 1 & 2 does not need any explanation, image 3 is RTL as made by IM; here i notice a wrong interpretation of glyph ligatures. Image 4 is almost prefect (if string is single line), but is pre-processed in alien application and no RTL is applied by IM.

Just for your possible curiosity, the ARABIC UNICODE string reverser that works can be found at: http://omar84.com/, Arabic Writer.
Interesting, it has full code exposed in its html.

Update: as bidirectional text is a complex subject and here is only Arabic, one of choice, I think reversing string is just a shortcoming effect to render correctly. Do there is any plan to include i18n library into IM? May be Pango...


Thanks all for your efforts.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-08T18:49:48-07:00
by anthony
The real problem with the dashes being placed on the wrong side is that the font switches direction.

I doubt IM could handle such change of direction, as it has no understanding that certian unicodes are performed in the oppiste direction. This is the job of a text processing package such as Pango, Not an Image processing package.


Prehaps an optional 'delegate' can be defined to call pango as a new type of text to image handling.
Something like pango:"text that may have some RTL text in it"

This way IM can make use of pango if available, but does not require it installed (not available in windows for example) to work for everything else. Just as it does for Postscript, and PDF file handling.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-11T14:59:55-07:00
by teebe
I found Pango library interesting but as all open source project difficult to implement (at least for me).
Interesting, I found another viewer (very popular and free) doing what i was expecting, that is RTL text overlays, at some costs in regard quality of anti-aliasing and easy of use (no arguments, mangling .ini instead).
I make my best wishes to all people that help in finding the solution.
Cheers.

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-12T03:14:16-07:00
by anthony
Would you like to share the name of that utility?

Re: possible bug -direction IM 6.7.0.2 Q16

Posted: 2011-06-12T03:40:07-07:00
by teebe
Yes irfanview.