Page 1 of 1

[RESOLVED] ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-18T15:44:24-07:00
by CatBus
I've noticed that when generating text via Pango, Windows builds of ImageMagick position combining diacritical marks incorrectly. It's pretty consistently wrong across scripts, affecting Arabic, Thai, etc. I've included a Navajo example below for an example with Latin characters.

Since the ImageMagick builds for Windows include Pango functionality instead of relying on an existing Pango install, I wonder if the Windows builds are just linking against an old/buggy version of Pango, or some related requirement like Harfbuzz.

In the example, notice that the diacritics above the a's on the second line are elevated way too high in the Windows render, and are correct on the Linux render. I added contrast that's not part of the Pango render, just for visibility.

Windows version: ImageMagick 6.9.3-5
Linux version: ImageMagick 6.9.3-8

Windows results:
Image

Linux results:
Image

I can provide a text file to produce these results as needed, but hopefully this is easily reproducible enough that might not be necessary.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-18T19:07:37-07:00
by snibgo
Well, if you want anyone to look into the report, you should provide a reproducible test.

Perhaps you are using different Pango libraries? "convert -list format" will tell you.

A pre-built Windows binary v6.9.2-5 shows:
PANGO* r-- Pango Markup Language (Pangocairo 1.36.0)

A Cygwin build of v6.9.3-7 shows:
PANGO* PANGO r-- Pango Markup Language (Pangocairo 1.36.8 )

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-18T20:49:54-07:00
by CatBus
Sure, I think this should be sufficient:

1) Make a text file test.txt and its contents should be Unicode text that I hope works here:

Code: Select all

<span font_desc="Arial">TEST
ách’ą́ą́h</span>
2) Run the command:

Code: Select all

convert pango:@test.txt test.png
On Windows, Notepad sticks a little byte-order mark character at the front of any UTF-8 text file which renders as garbage, but you can trim that out or leave it, it doesn't affect the results. Linux renders everything correctly, Windows doesn't (looking like the example above). I use the same actual Arial font file from Windows on Linux, as I'm not sure the free web font is as current and contains all necessary glyphs.

My pre-built Windows binary also shows: Pango Markup Language (Pangocairo 1.36.0)

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T06:48:31-07:00
by snibgo
On Windows 8.1, IM v6.9.2-6 creating a BAT file in UTF-8:

Code: Select all

%IM%convert -pointsize 50 pango:"TEST\nách’ą́ą́h" diacrit_0.png

%IM%convert -pointsize 50 -font Arial pango:"TEST\nách’ą́ą́h" diacrit_1.png

%IM%convert -pointsize 50 -font Consolas pango:"TEST\nách’ą́ą́h" diacrit_2.png
The results are:
Image
Image
Image

I conclude the problem is with my Arial font file. However, using Arial font in Notepad, the diacriticals display correctly. So I don't know where the problem lies.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T09:27:52-07:00
by CatBus
I've found the same problem in the following languages and fonts:

Hindi: Mangal
Arabic, Persian/Farsi & Navajo: Arial
Thai: Tahoma

So we know that the same script with the same fonts, running on different platforms, gets you different results.
We also now know that the same script on the same platform, with different fonts, gets you different results.

So I'd conclude differently--that the behavior is both platform- and font-specific. The bug on Windows is font-specific, but there simply is no bug on Linux, which to me means it cannot be entirely a font problem. I assume that there's some sort of diacritic placement data in the font file that the Linux version reads correctly and Windows does not, and the other font files handle diacritic placement differently.

I'd be interested to see what results you get with the Cygwin version (Pangocairo 1.36.8 ) on Windows, since the Pangocairo version is newer than the Windows builds.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T09:35:13-07:00
by fmw42
What are your versions of freetype and fontconfig delegates? Are they the same on each platform?

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T10:11:17-07:00
by CatBus
I really don't know how to answer that. I'd imagine the Windows builds are very different in many ways than ImageMagick on Linux--certainly the Pangocairo versions are different.

Windows (bug) has Pangocairo 1.36.0
Linux (no bug) has Pangocairo 1.36.8

Anything else, you'd have to tell me how to grab that info for Linux and Windows.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T10:18:11-07:00
by fmw42
You can do

convert -list format

to get some:


TTC* TTF r-- TrueType font collection (Freetype 2.6.2)
TTF* TTF r-- TrueType font (Freetype 2.6.2)


On unix, you can do


find /opt | grep "fontconfig"
or
find /usr | grep "fontconfig"


Or just get the most current versions and put them on your systems and see if that helps. Same with Pango/Cairo.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T10:49:27-07:00
by CatBus
Windows has Freetype 2.6.2
Linux has Freetype 2.4.11

My Linux package manager says fontconfig 2.11.0-3.2

I'm not sure where I would get more current versions of Pango, Freetype, etc for the pre-packaged binary Windows builds. Would that be new versions of the IM_MOD_RL_pango_.dll, IM_MOD_RL_ttf_.dll etc?

Linux is already working fine, so the system I know how to update doesn't need updating!

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T11:09:55-07:00
by dlemstra
I will upgrade Pango in the Windows distribution later this week. Not sure if that helps but prob still not a bad idea to do :)

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-19T11:12:31-07:00
by CatBus
I will absolutely test it for this issue and report back.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-22T14:31:45-07:00
by dlemstra
Pango has been upgraded to 1.40.1 this will be included in the next release of ImageMagick (v6.9.3-9)

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-22T17:22:10-07:00
by magick
The release date for ImageMagick 6.9.3-9 and ImageMagick 7.0.1-1 on April 30th.

Re: ImageMagick+Pango positions diacritical marks incorrectly (Windows-only)

Posted: 2016-04-30T21:12:49-07:00
by CatBus
Tested and confirmed fixed under every test scenario I've found in ImageMagick 7.0.1. Could have been lots of things, but I'm blaming the Pango version.