ImageMagick loses fonts supplied by FontConfig

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
edwin
Posts: 4
Joined: 2012-10-20T13:06:57-07:00
Authentication code: 67789

ImageMagick loses fonts supplied by FontConfig

Post by edwin »

I was trying to use the Arial Narrow set of fonts but it would only ever show one and leave out the bold/italic variations. It would be easy enough for me to add them to type.xml, but that's not really a solution when things get promoted to user software.

Since I don't like unsolved mysteries, I started digging.

From the LoadFontConfigFonts function I found that ImageMagick creates its font name by concaternating the family and style strings. I did some tests with fontconfig, and it turns out that this combination is not guaranteed to be unique. For instance, for Arial Narrow the returned family is always "Arial" and the style is always "Narrow". Which is likely the source of the problem.

Since software like LibreOffice does present the font separate, I had a look at the fonts with fc-query as well. It turns out that these fonts have two (english) family names and style strings. "Arial" and "Narrow" which ImageMagick uses. And "Arial Narrow" and "Regular/Bold/...", which is the one more suitable for ImageMagick. I suppose the first set is for combining it with Arial as condensed width.

Fc-query also showed a simple solution to the problem. There is a 'fullname' property (FC_FULLNAME) that provides more complete names for all fonts that set it. Some checking revealed that it appears to be set for all TTF fonts to something close to family+style, but with full styles for fonts like Arial Narrow. The differences I noticed is that it adds a space to some family names and does not include "Regular" as a style. Although this is a small behaviour change, it's better than dropping fonts.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick loses fonts supplied by FontConfig

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.0-2 Beta available by sometime tomorrow. Thanks.
edwin
Posts: 4
Joined: 2012-10-20T13:06:57-07:00
Authentication code: 67789

Re: ImageMagick loses fonts supplied by FontConfig

Post by edwin »

Thanks for the very quick response!

I checked the code in SVN and it looks like you forgot to add FC_FULLNAME in the FcObjectSetBuild line.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagick loses fonts supplied by FontConfig

Post by magick »

We had the the correct FcObjectSetBuild() call in our development environment but forgot to export it to SVN. Fixed now. Thanks.
Post Reply