Page 1 of 2

"montage: unable to read font (null)"

Posted: 2010-03-15T13:43:34-07:00
by naoliv
Hi!

We are having some issues related with fonts in ImageMagick (version 6.0.0-4) on Debian (see http://bugs.debian.org/573983) where an user is having this problem (that I cannot reproduce):

Code: Select all

$  montage test.jpg test1.jpg
montage: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1044.
and problems like this:

Code: Select all

convert -size 320x85 xc:transparent -font Bookman-DemiItalic \
  -pointsize 72 -draw "text 25,60 'Magick'" -channel RGBA \
  -blur 0x6 -fill darkred -stroke magenta \
  -draw "text 20,55 'Magick'" fuzzy-magick.png

  On older imagemagick, it works fine.

  On the newer one, it works, but issues the following warnings:

convert: unable to read font `Bookman-DemiItalic' @
warning/annotate.c/RenderType/807.
convert: unable to read font `Bookman-DemiItalic' @
error/annotate.c/RenderFreetype/1044.
(...)
I am thinking if this could be related with viewtopic.php?f=2&t=15355 where we removed these lines from config/type.xml.in:

Code: Select all

<typemap>
  @type_include_files@
</typemap>
Our final type.xml file is this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE typemap [
<!ELEMENT typemap (type)+>
<!ELEMENT type (#PCDATA)>
<!ELEMENT include (#PCDATA)>
<!ATTLIST type name CDATA #REQUIRED>
<!ATTLIST type fullname CDATA #IMPLIED>
<!ATTLIST type family CDATA #IMPLIED>
<!ATTLIST type foundry CDATA #IMPLIED>
<!ATTLIST type weight CDATA #IMPLIED>
<!ATTLIST type style CDATA #IMPLIED>
<!ATTLIST type stretch CDATA #IMPLIED>
<!ATTLIST type format CDATA #IMPLIED>
<!ATTLIST type metrics CDATA #IMPLIED>
<!ATTLIST type glyphs CDATA #REQUIRED>
<!ATTLIST type version CDATA #IMPLIED>
<!ATTLIST include file CDATA #REQUIRED>
]>
Did we manage to create an invalid type.xml file (and if yes, how could we fix it) or is it some problem with ImageMagick, please?

Really thank you!

Re: "montage: unable to read font (null)"

Posted: 2010-03-15T16:29:23-07:00
by magick
is the <typemap> element included in your XML file? If not, try it. It should look like this:
  • <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE typemap [
    <!ELEMENT typemap (type)+>
    <!ELEMENT type (#PCDATA)>
    <!ELEMENT include (#PCDATA)>
    <!ATTLIST type name CDATA #REQUIRED>
    <!ATTLIST type fullname CDATA #IMPLIED>
    <!ATTLIST type family CDATA #IMPLIED>
    <!ATTLIST type foundry CDATA #IMPLIED>
    <!ATTLIST type weight CDATA #IMPLIED>
    <!ATTLIST type style CDATA #IMPLIED>
    <!ATTLIST type stretch CDATA #IMPLIED>
    <!ATTLIST type format CDATA #IMPLIED>
    <!ATTLIST type metrics CDATA #IMPLIED>
    <!ATTLIST type glyphs CDATA #REQUIRED>
    <!ATTLIST type version CDATA #IMPLIED>
    <!ATTLIST include file CDATA #REQUIRED>
    ]>
    <typemap>
    </typemap>
if that does not fix the problem, we'll try to reproduce the problem and come up with a patch.

Re: "montage: unable to read font (null)"

Posted: 2010-03-15T16:38:10-07:00
by naoliv
Hi!

There was no

Code: Select all

<typemap>
</typemap>
in type.xml. But even after including these two lines:

Code: Select all

$ convert -size 320x85 xc:transparent -font Bookman-DemiItalic -pointsize 72 -draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta -draw "text 20,55 'Magick'" output.png

convert: unable to read font `Bookman-DemiItalic' @ warning/annotate.c/RenderType/807.
We have a new comment on our bug report (http://bugs.debian.org/573983) that maybe could help:
I think I have a better idea of what is happening: if I use one of the
fonts listed by

~ convert -list font

I get no error, and the output looks fine. Looking closer, I find that
there are several fonts missing from the newer version of imagemagick,
namely, the postscript fonts:

diff im-fontlist.old im-fontlist.new
1,8d0
< Font: AvantGarde-Book
< Font: AvantGarde-BookOblique
< Font: AvantGarde-Demi
< Font: AvantGarde-DemiOblique
< Font: Bookman-Demi
< Font: Bookman-DemiItalic
< Font: Bookman-Light
< Font: Bookman-LightItalic
53,56d44
< Font: Courier
< Font: Courier-Bold
< Font: Courier-BoldOblique
< Font: Courier-Oblique
64,72d51
< Font: fixed
< Font: Helvetica
< Font: Helvetica-Bold
< Font: Helvetica-BoldOblique
< Font: Helvetica-Narrow
< Font: Helvetica-Narrow-Bold
< Font: Helvetica-Narrow-BoldOblique
< Font: Helvetica-Narrow-Oblique
< Font: Helvetica-Oblique
177,180d155
< Font: NewCenturySchlbk-Bold
< Font: NewCenturySchlbk-BoldItalic
< Font: NewCenturySchlbk-Italic
< Font: NewCenturySchlbk-Roman
197,200d171
< Font: Palatino-Bold
< Font: Palatino-BoldItalic
< Font: Palatino-Italic
< Font: Palatino-Roman
202,206d172
< Font: Symbol
< Font: Times-Bold
< Font: Times-BoldItalic
< Font: Times-Italic
< Font: Times-Roman

I think I've understood the problem: when a font isn't found,
imagemagick falls back onto using helvetica (line 1032 of
magick/annotate.c). On the older imagemagick, as the postscript fonts
were automatically included with

<typemap>
@type_include_files@
</typemap>

there was no problems. On the newer version, Helvetica is missing, so it
isn't found at all. That's pretty bad for the default font !

I don't know who's to blame: how comes helvetica doesn't show up in
fontconfig ? gs-fonts are installed, which is where it should be coming,
shouldn't it ?

Re: "montage: unable to read font (null)"

Posted: 2010-03-15T17:48:32-07:00
by magick
We can reproduce the problem and have a tentative patch. We added
  • if (type_info == (const TypeInfo *) NULL)
    type_info=GetTypeInfoByFamily("Utopia",draw_info->style,
    draw_info->stretch,draw_info->weight,&image->exception);
just before
  • if (type_info == (const TypeInfo *) NULL)
    type_info=GetTypeInfoByFamily("arial",draw_info->style,
    draw_info->stretch,draw_info->weight,&image->exception);
in magick/annotate.c

This looks for the "Utopia" family presumably available from fontconfig. Is there a better choice for the default font family?

Re: "montage: unable to read font (null)"

Posted: 2010-03-17T07:49:20-07:00
by naoliv
Hi!

With the patch applied the problem is still present:
I've just built and installed a set of local imagemagick packages with
the suggested patch from upstream (adding "Utopia" as an alternative
font family) and I'm afraid I have to report that I still get the same
problem:

$ montage IMG_3058.jpg IMG_3059.jpg
montage: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1047.

(the change in line number being purely the addition of the patch).
But there is some light on why ImageMagick isn't finding the ghostscripts fonts, even with them installed:
Nelson A. de Oliveira wrote:
> One thing that I don't understand however (and if somebody knows why,
> I would be grateful for an explanation) is why fontconfig/imagemagick
> doesn't see the ghostscripts fonts (and why it's necessary to
> explicitly include them in type.xml).

Argh ! I was just writing up a long mail explaining that, in part.
I'll send it along in a few minutes.

The thing is that the font "helvetica" doesn't exist as such for
fontconfig, but through something like a matching mechanism:

~ fc-match helvetica
n019003l.pfb: "Nimbus Sans L" "Regular"

The *real* font behind is Nimbus-Sans (in my case, but see the mail
I'll send in a minute).

To do well, on would have to use the equivalent of fc-match somewhere
around the place where imagemagick falls back onto Helvetica as default.
I don't have any idea of how to do that, but I'm pretty sure upstream would.

Re: "montage: unable to read font (null)"

Posted: 2010-03-17T08:23:57-07:00
by magick
GetTypeInfoByFamily() is similar to fc-match. Can you post the output of
  • identify -list font
That will tell us which fonts are available on your system. Also, see if ImageMagick 6.6.0-6, the lastest release finds a default font. Otherwise we're not sure what the best method to reliably find a default font on a particular system.

We'll also try finding a Debian system so I can debug this problem.

Re: "montage: unable to read font (null)"

Posted: 2010-03-17T08:36:24-07:00
by naoliv
http://people.debian.org/~naoliv/misc/i ... fonts1.txt is the output of "identify -list font".
http://people.debian.org/~naoliv/misc/i ... fonts2.txt is the result without including type-ghostscript.xml in type.xml

Re: "montage: unable to read font (null)"

Posted: 2010-03-17T09:26:29-07:00
by naoliv
And testing with 6.6.0-6 with type-ghostscript.xml reference removed from type.xml, I still see the same message:

Code: Select all

$ convert -size 320x85 xc:transparent -font Bookman-DemiItalic -pointsize 72 -draw "text 25,60  Magick'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta -draw "text 20,55 'Magick'" output.png

convert: unable to read font `Bookman-DemiItalic' @ warning/annotate.c/RenderType/807.

Re: "montage: unable to read font (null)"

Posted: 2010-03-23T01:39:53-07:00
by broucaries
Any news of this anoyying bug ?

Regards

Bastien

Re: "montage: unable to read font (null)"

Posted: 2010-03-23T01:45:40-07:00
by broucaries
BTW something like this would help you to select a default font

sans = FcPatternBuild (NULL,
FC_FAMILY, FcTypeString, "sans",
FC_PIXEL_SIZE, FcTypeDouble, size,
FC_ANY_METRICS, FcTypeBool, FcTrue,
NULL);

matched = FcFontMatch (NULL, sans, &result);

Bastien

Re: "montage: unable to read font (null)"

Posted: 2010-03-23T04:35:43-07:00
by magick
Download the latest release and let us know if our patch resolved the problem. And thanks for the tip on using FcFontMatch().

Re: "montage: unable to read font (null)"

Posted: 2010-07-10T13:23:41-07:00
by fletcher.mcbeth
Using:

ImageMagick-x86_64-apple-darwin10.4.0.tar (ImageMagick-6.6.3) on a MacBookPro Version 10.6.4

With the instruction:

montage [0-9].png -tile 1x10 -geometry 522x304+0+0 strip.png

I get:

montage: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1056.

Re: "montage: unable to read font (null)"

Posted: 2011-06-30T09:00:08-07:00
by broucaries
This bug is still here

Re: "montage: unable to read font (null)"

Posted: 2011-06-30T10:00:39-07:00
by magick
Do you have an example to reproduce the problem? We're using ImageMagick 6.7.0-9 and we cannot produce an "unable to read font" exception.

Re: "montage: unable to read font (null)"

Posted: 2011-07-14T13:13:14-07:00
by broucaries
config/type.xml is only:
<typemap>
</typemap>

So I use fc by default.

Doing montage rose: fail with exception

Bastien