freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] putting text in a box


From: Dave Calkins
Subject: Re: [ft] putting text in a box
Date: Wed, 20 Jan 2010 08:19:50 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0


It seems like the bounding box calculation is always correct.  The
problem is that the descender I'm querying is for the font face in
general which I assume accounts for every glyph in the font.
If you have a negative value in the bbox, this is the amount below the
baseline.

I'm not getting negative values in the bounding box. I'm getting a positive overall width and height for the text string in question (although I should say I'm calling the FreeTypeGL bounding box method, so I suppose I need to see which FreeType calls thats using). And I can verify that this bounding box is correct. If I render and check the bounding box, I can, in MSPaint for example, line it up with a box that size and it does exactly enclose all the text. So the bounding box looks great.

The problem is that I need to know where to render the text. When I set the output position, this positions the baseline of the text. So the only way to put the text exactly in that box (I think) is to know the descender values for the individual chars in the specific string I'm rendering.

I can get a descender value for the font face overall, but this ends up being too large (for some fonts) and if I use this to position the string the string is too high since the specific string doesn't actually have descender values that large.


Any suggestions on computing the descenders for individual glyphs?
Calculate the bbox for individual glyphs.  In most cases, a cbox
should be sufficient, BTW.

I'll look again today, but I don't recall seeing a descender value for a glyph. The example code I looked at computed a bounding box, telling me what box would enclose the char, but I need the distance the char extends below the baseline. I could just have overlooked something though.
I took a look at the glyph metrics from FreeType, but these didn't
seem to help.  For example, I found a case where "E" seemed to
report a descender (comparing height and vertBearingY).
It's easily possible that the glyph `E' descends slightly (due to
serifs, for example).

In that case, the descent was definitely not from a serif. It was a value much larger than you'd expect. I drew the "E", then drew a cross-hair at the output positionn and there was really no descent.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]