[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft] putting text in a box
From: |
Dave Calkins |
Subject: |
[ft] putting text in a box |
Date: |
Tue, 19 Jan 2010 20:33:44 -0500 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 |
Given an input text string, a font family, and a pointsize, I'd like to
draw a filled rectangle background and then draw the text on top of that.
The key is I want the rectangle background to be just large enough to
contain all the text.
The trouble I'm having is that when I render the text (I'm using
FreeTypeGL to render in OpenGL), the output position is used to place
the *baseline* of the text. I seem to be able to accurately compute the
overall bounding box of the text, however, I'm having trouble accurately
figuring out the descender for my string.
And this accuracy is a function of which font I choose.
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.
However, if I'm trying to render a particular text string, I only want
the largest descender for the glyphs in that string.
Any suggestions on computing the descenders for individual glyphs?
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).
Any advice on how to properly place a text string exactly into a rectangle?
- [ft] putting text in a box,
Dave Calkins <=
- Re: [ft] putting text in a box, Werner LEMBERG, 2010/01/19
- Re: [ft] putting text in a box, Dave Calkins, 2010/01/20
- Re: [ft] putting text in a box, Werner LEMBERG, 2010/01/20
- Re: [ft] putting text in a box, Dave Calkins, 2010/01/20
- Re: [ft] putting text in a box, Werner LEMBERG, 2010/01/20
- Re: [ft] putting text in a box, dave, 2010/01/20
- Re: [ft] putting text in a box, Werner LEMBERG, 2010/01/20
- Re: [ft] putting text in a box, dave, 2010/01/20
- Re: [ft] putting text in a box, Werner LEMBERG, 2010/01/21
- RE: [ft] putting text in a box, David Bevan, 2010/01/21