[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3.22 TTF_SizeUNICODE

int TTF_SizeUNICODE(TTF_Font *font, const Unit16 *text, int *w, int *h)

font
The loaded font to use to calculate the size of the string with.
text
The UNICODE null terminated string to size up.
w
pointer to int in which to fill the text width, or NULL for no desired return value.
h
pointer to int in which to fill the text height, or NULL for no desired return value.

Calculate the resulting surface size of the UNICODE encoded text rendered using font. No actual rendering is done, however correct kerning is done to get the actual width. The height returned in h is the same as you can get using 3.3.10 TTF_FontHeight.
NOTE: Passing a NULL font into this function will cause a segfault. NOTE: Passing a NULL text into this function will result in undefined behavior.

Returns: 0 on success with the ints pointed to by w and h set as appropriate, if they are not NULL. -1 is returned on errors, such as a glyph in the string not being found.

 
// get the width and height of a string as it would be rendered in a loaded font
//TTF_Font *font;
int w,h;
Uint16 text[]={'H','e','l','l','o',' ',
               'W','o','r','l','d','!'};
if(TTF_SizeUNICODE(font,text,&w,&h)) {
    // perhaps print the current TTF_GetError(), the string can't be rendered...
} else {
    printf("width=%d height=%d\n",w,h);
}

See Also:
3.3.20 TTF_SizeText,
3.3.21 TTF_SizeUTF8,
3.4.3 TTF_RenderUNICODE_Solid,
3.4.7 TTF_RenderUNICODE_Shaded,
3.4.11 TTF_RenderUNICODE_Blended



This document was generated on November, 13 2009 using texi2html