Bad fonts, no error?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Bad fonts, no error?

Post by rmabry »

Should bad fonts give no error but still generate an image?

I grabbed these two TTF's:

http://www.getfreefonts.info/free_font.almontesnow.html

http://www.getfreefonts.info/free_font.altea.html

Following Anthony's scripts, I tried

convert -background lightblue -fill blue -font almosnow.ttf -pointsize 72 label:Samantha almosnow-pointsize.png

and

convert -background lightblue -fill blue -font altea.ttf -pointsize 72 label:Samantha altea-pointsize.png

The first worked well but the second gave a 776x1 "one-dimensional" result. What the foo? Is there a detectable error that should be reported? (I'm presuming that this is a font bug and not an IM bug.)

When -size was stipulated, both worked properly.

convert -background lightblue -fill blue -font almosnow.ttf -size 360x100 -gravity center label:Samantha almosnow-size.png

convert -background lightblue -fill blue -font altea.ttf -size 360x100 -gravity center label:Samantha altea-size.png

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Bad fonts, no error?

Post by magick »

The font is returning bogus font metrics which prevents the label coder from computing a proper bounding box. Add -debug annotate to your command line and it reports the font metrics for the font for your inspection.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Bad fonts, no error?

Post by rmabry »

magick wrote:The font is returning bogus font metrics which prevents the label coder from computing a proper bounding box.
And is there a way that IM can glean something so obviously bogus? If so, an error message could be given.
Add -debug annotate to your command line and it reports the font metrics for the font for your inspection.
Not for my inspection, but maybe for you and your brother wizards! Here it is:
2008-12-28T03:44:38+00:00 0:01 0.344u 6.4.8 Annotate convert[3152]: annotate.c/RenderFreetype/1451/Annotate
Font f:/windows/fonts/altea.ttf; font-encoding none; text-encoding none; pointsize 72
2008-12-28T03:44:38+00:00 0:01 0.344u 6.4.8 Annotate convert[3152]: annotate.c/G
etTypeMetrics/1001/Annotate
Metrics: text: Samantha; width: 773.563; height: 0; ascent: 0; descent: 0; max advance: 182; bounds: 1.4375,-1.15625 105.109,92.2969; origin: 773,0; pixels per em: 72,72; underline position: -2.34375; underline thickness: 0.78125
2008-12-28T03:44:38+00:00 0:01 0.344u 6.4.8 Annotate convert[3152]: annotate.c/RenderFreetype/1451/Annotate
Font f:/windows/fonts/altea.ttf; font-encoding none; text-encoding none; point
size 72
2008-12-28T03:44:38+00:00 0:01 0.359u 6.4.8 Annotate convert[3152]: annotate.c/GetTypeMetrics/1001/Annotate
Metrics: text: Samantha; width: 773.563; height: 0; ascent: 0; descent: 0; max
advance: 182; bounds: 1.4375,-1.15625 105.109,92.2969; origin: 773,0; pixels per em: 72,72; underline position: -2.34375; underline thickness: 0.78125
2008-12-28T03:44:38+00:00 0:01 0.359u 6.4.8 Annotate convert[3152]: annotate.c/R
enderFreetype/1451/Annotate
Font f:/windows/fonts/altea.ttf; font-encoding none; text-encoding none; pointsize 72
All that catches my untrained eye is "height: 0" which just seems wrong. Are there certain obvious things that IM can catch?

Rick
Post Reply