[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
int *minx, int *maxx,
int *miny, int *maxy,
int *advance)
Get desired glyph metrics of the UNICODE chargiven in ch from the loaded font.
NOTE: Passing a NULL font into this function will cause a segfault.
Returns: 0 on success, with all non-NULL parameters set to the glyph metric as appropriate. -1 on errors, such as when the glyph named by ch does not exist in the font.
|
This diagram shows the relationships between the values:
Here's how the numbers look:
|
We see from the Line Skip that each line of text is 55 pixels high,
including spacing for this font.
The Ascent-Descent=52, so there seems to be 3 pixels worth of space between lines for this font.
Let's say we want to draw the surface of glyph 'g' (retrived via
3.4.4 TTF_RenderGlyph_Solid or a similar function), at coordinates (X,Y) for the top left corner of the desired location.
Here's the math using glyph metrics:
|
Let's say we want to draw the same glyph
at coordinates (X,Y) for the origin (on the baseline) of the desired location.
Here's the math using glyph metrics:
|
NOTE: The only difference between these example is the +TTF_FontAscent(font)
used in the top-left corner algorithm.
NOTE: These examples assume that 'g' is present in the font!
NOTE: In practice you may want to also subtract TTF_GetFontOutline(font)
from your X and Y coordinates to keep the glyphs in the same place no matter what outline size is set.
See the web page at The FreeType2 Documentation Tutorial for more.
Any glyph based rendering calculations will not result in accurate kerning between adjacent glyphs. (see section Kerning)
See Also:
3.3.10 TTF_FontHeight,
3.3.11 TTF_FontAscent,
3.3.12 TTF_FontDescent,
3.3.13 TTF_FontLineSkip,
3.3.20 TTF_SizeText,
3.3.21 TTF_SizeUTF8,
3.3.22 TTF_SizeUNICODE,
3.3.18 TTF_GlyphIsProvided,
3.3.4 TTF_GetFontOutline
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |