SDL_ttf

SDL_ttf > Functions > Attributes

TTF_GlyphMetrics

int TTF_GlyphMetrics(TTF_Font *font, Uint16 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance)

font

ch

minx

maxx

miny

maxy

advance

Gets the glyph metrics from the font file.

NOTE: Passing a NULL font into this function will cause a segfault.

NOTE: This image may help understand the different metrics.

http://freetype.sourceforge.net/freetype2/docs/glyphs/Image3.png (from the FreeType page).

Returns:

// get the character's metrics from the loaded font
//TTF_Font *font;
int error;
int minx, maxx, miny, maxy, advance;
char c = 'x';
error=TTF_GlyphMetrics(font, c, &minx, &maxx, &miny, &maxy, &advance);
if(error)
  printf("Error, could not find character %c.", c);
else
  printf("x = %i to %i, y = %i to %i, advance = %i.", minx, maxx, miny, maxy, advance);

See Also

SDL_ttf_kopie/Functions/Attributes/TTF_TTF_GlyphMetrics (last edited 2009-02-25 23:12:03 by sign-4d0949c8)