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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post 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.
Last edited by CatBus on 2016-05-05T12:04:45-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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 )
snibgo's IM pages: im.snibgo.com
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post 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)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

What are your versions of freetype and fontconfig delegates? Are they the same on each platform?
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post 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!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post 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 :)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post by CatBus »

I will absolutely test it for this issue and report back.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra »

Pango has been upgraded to 1.40.1 this will be included in the next release of ImageMagick (v6.9.3-9)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick »

The release date for ImageMagick 6.9.3-9 and ImageMagick 7.0.1-1 on April 30th.
CatBus
Posts: 11
Joined: 2016-04-18T15:28:21-07:00
Authentication code: 1151

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

Post 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.
Post Reply