Page 1 of 1

Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T09:23:58-07:00
by rotem
Hey,

I'm using a font called grobold (https://drive.google.com/file/d/0B3Czzl ... sp=sharing)

When using label with this command

Code: Select all

convert -background none -debug annotate "-font" "./assets/grobold.ttf" -pointsize 35 label:'!' -trim -write info: x.png
this is the result (29px height)

Image

and when using annotate/draw with this command

Code: Select all

convert -size 400x400 -background none xc:none "-font" "./assets/grobold.ttf" -pointsize 35 -annotate +200+200 '\!' -trim +write info: x.png
this is the result (34px height)

Image

Is that a bug? what am I doing wrong?

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T09:38:58-07:00
by snibgo
"-trim" should usually be followed by "+repage".

"label:" automatically chooses a canvas size based on font metrics. For some fonts, glyphs can exceed these boundaries. Try it with:

Code: Select all

label:'\n ! \n'

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T11:49:19-07:00
by rotem
Cool snibgo, it's working. However, I also need to use the output in order to get the font's boundaries.

For example, this output will allow me to understand that this character have 7px boundary from top 1px from the right, and 8px from the bottom.

Code: Select all

label:a LABEL 21x21 22x36+0+7
If I use your method the output would be very different.

Do you have any other idea what can I do?

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T12:18:56-07:00
by snibgo
So you would want negative numbers where the glyph exceeds the boundaries given by the font metrics? Then I think you need to parse the font metrics, but I don't know much about that.

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T13:27:47-07:00
by rotem
How do I get the font metrics?

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T13:34:53-07:00
by snibgo
From your first command. The text output will include something like:

Code: Select all

  Metrics: text: '!'; width: 22.4688; height: 40; ascent: 32; descent: -7; max advance: 70; bounds: 1.53125,0  6.8125,26; origin: 24,0; pixels per em: 35,35; underline position: -4.5625; underline thickness: 2.34375

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T13:44:07-07:00
by rotem
oh, yeah I'm reading them metrics. I also don't know how to parse them.

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-14T14:33:23-07:00
by fmw42
What is your IM version and platform? Please always provide that since IM syntax and scripting can be different.

Please read the top-most post in this forum at viewtopic.php?f=1&t=9620

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-15T00:21:51-07:00
by rotem
Hey fmw42,

as I understand this is not a bug because what snibgo said:
"label:" automatically chooses a canvas size based on font metrics. For some fonts, glyphs can exceed these boundaries.
right?

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-15T09:18:45-07:00
by fmw42
Yes. But my point was that windows and unix syntax may differ (especially for scripting) and issues may occur because of different IM versions. So it is always a good idea to provid yur IM version and platform. You said you did not know how to parse the font metric. That would need some OS scripting which would be different depending upon your OS (Windows vs Unix). So we need to know this information since we all do not script in both Unix and Windows. So different people might need to help you parse that.

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-15T10:18:48-07:00
by snibgo
snibgo wrote:Then I think you need to parse the font metrics, but I don't know much about that.
To clarify: syntactic parsing is easy enough. In Windows, just use a FOR loop with appropriate tokens, delims etc. But I don't know much about what the numbers actually mean. See http://www.imagemagick.org/Usage/text/#font_info

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-16T05:23:56-07:00
by rotem
fmw42, yeah I understand what you mean and from now on I will add my OS and IM version. However, my question was about what the number actually means (just like snibgo said in the last comment). Sorry for not being clear enough.

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-16T10:28:45-07:00
by fmw42
the diagram at http://www.imagemagick.org/Usage/text/#font_info is all I know for such information

Re: Different results for label and annotate/draw (maybe bug in IM)

Posted: 2016-07-16T23:07:41-07:00
by rotem
Yeah, well as one that spent a lot of time investigating font metrics I can tell you that I couldn't find anyway to corollate the diagram with the -debug annotate output.