Page 1 of 1
Yet another QueryFontMetrics question
Posted: 2007-07-15T17:55:21-07:00
by Ryland
QueryFontMetrics() returns the ascender and descender value for a font, and the height and width of a text string, but it doesn't give a relation between the two, that is, it doesn't give the font's actual height above the baseline (which is often different from the ascender value). Is there any way to do this, other than a hack such as getting the height of a capital M and calculating the height from baseline from that?
Re: Yet another QueryFontMetrics question
Posted: 2007-07-15T18:26:15-07:00
by magick
QueryFontMetrics returns
- % 0 character width
% 1 character height
% 2 ascender
% 3 descender
% 4 text width
% 5 text height
% 6 maximum horizontal advance
However we have these additional values available which we currently do not return:
- % 7 bounding box: x1
% 8 bounding box: y1
% 9 bounding box: x2
% 10 bounding box: y2
% 11 origin: x
% 12 origin: y
We can expose the other values if they will return what you need. If not, define precisely what you need by consulting the source. See RenderFreetype() in magick/annotate.c around line 1360.
Re: Yet another QueryFontMetrics question
Posted: 2007-07-15T18:52:43-07:00
by Ryland
Well, it would be great to have those values, but if you're talking about releasing an updated version of ImageMagick, I'm not sure that would help me, as I'm using a webhosting service and I don't know how they'll feel about updating. (They're using version 6.2.9, for what it's worth.) I was just wondering if someone else had encountered the same problem and figured out a work-around.
Re: Yet another QueryFontMetrics question
Posted: 2007-10-03T03:19:27-07:00
by anthony
AN alturnative way is to actually render the character then trim it to determine the information. It will be relatively slow but it will always work.
I do some simular statistical gathering in IM Examples for the command line interface, but the principle is that same. For PerlMagick the image does not need to be written or exposed outside the script.
See
Determining Font Metrics, without using an API for more info.