# TrueType font rendering

- The TT font structure
- sge_TTF_Init
- sge_TTF_OpenFont
- sge_TTF_OpenFontIndex
- sge_TTF_OpenFontRW
- sge_TTF_OpenFontIndexRW
- sge_TTF_CloseFont
- sge_TTF_ByteSwappedUNICODE
- sge_TTF_SetFontSize
- sge_TTF_SetFontSizeDPI
- sge_TTF_TextSize
- sge_TTF_FontHeight
- sge_TTF_FontAscent
- sge_TTF_FontDescent
- sge_TTF_FontLineSkip
- sge_TTF_FontFaces
- sge_TTF_FontFaceIsFixedWidth
- sge_TTF_FontFaceFamilyName
- sge_TTF_FontFaceStyleName
- sge_TTF_AAOn/Off/_Alpha
- sge_TTF_SetFontStyle
- sge_TTF_GetFontStyle

To the sge_tt_textout() functions>>
The TT font structure

    typedef struct{
      ...
    } sge_TTFont;

When working with TTF functions you must give a pointer to the font structure. To open a new font (structure) use sge_TTF_OpenFont() and when finished use sge_TTF_CloseFont().
int sge_TTF_Init(void)
Starts the FreeType engine, must be called before any of the other TTF functions. Returns 0 on success.
sge_TTFont *sge_TTF_OpenFont(char *file, int ptsize)
Opens the given ttf file and sets the font size to ptsize. Returns a pointer to the new font.
sge_TTFont *sge_TTF_OpenFontIndex(char *file, int ptsize, long index, int xdpi, int ydpi)
Same as sge_TTF_OpenFont() but you can also set the font face index and the dpi used. Font face #0 and 96x96dpi is used with sge_TTF_OpenFont().
sge_TTFont *sge_TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize, int xdpi, int ydpi)
Same as sge_TTF_OpenFont() but reads from a SDL_RWops stream. The stream is closed at sge_TTF_CloseFont() if freesrc > 0.
sge_TTFont *sge_TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index, int xdpi, int ydpi)
Same as sge_TTF_OpenFontRW() but you can also set the font face index.
void sge_TTF_CloseFont(sge_TTFont *font)
Removes font from memory.
void sge_TTF_ByteSwappedUNICODE(int swapped)
This function tells the library whether UNICODE text is generally byteswapped. A UNICODE BOM character (UNICODE_BOM_NATIVE or UNICODE_BOM_SWAPPED) at the beginning of a string will override this setting for that string.
int sge_TTF_SetFontSize(sge_TTFont *font, int ptsize)
Change the size of the given font. Returns 0 on success.
int sge_TTF_SetFontSizeDPI(sge_TTFont *font, int ptsize, int xdpi, int ydpi)
Same as sge_TTF_SetFontSize() but you can also set the dpi used.
SDL_Rect sge_TTF_TextSize(sge_TTFont *Font, char *Text)
Returns the width (.w) and height (.h) of the text with the given font.
int sge_TTF_FontHeight(sge_TTFont *font)
Returns the distance between the fonts baseline and the top of the highest character.
int sge_TTF_FontAscent(sge_TTFont *font)
Returns the ascent of the font.
int sge_TTF_FontDescent(sge_TTFont *font)
Returns the descent of the font.
int sge_TTF_FontLineSkip(sge_TTFont *font)
Returns the recommended line skip for this font.
long sge_TTF_FontFaces(sge_TTFont *font)
Returns the number of font faces available for this font.
int sge_TTF_FontFaceIsFixedWidth(sge_TTFont *font)
Returns true if the used font face is fixed width.
char *sge_TTF_FontFaceFamilyName(sge_TTFont *font)
Returns the family name of the selected font face.
char *sge_TTF_FontFaceStyleName(sge_TTFont *font)
Returns the style name of this font face.
void sge_TTF_AAOn(void)
void sge_TTF_AAOff(void)
void sge_TTF_AA_Alpha(void)
Turns anti-aliasing for truetype output on/off. Defaults to ON. You can also enable alpha blending support (very nice but slow).
void sge_TTF_SetFontStyle(sge_TTFont *font, Uint8 style)
Sets the font style.
Flags: (may be ORed, eg. SGE_TTF_BOLD|SGE_TTF_ITALIC)
SGE_TTF_NORMAL - The default style.
SGE_TTF_BOLD - Bold.
SGE_TTF_ITALIC - Italic.
SGE_TTF_UNDERLINE - Underlined.
Uint8 sge_TTF_GetFontStyle(sge_TTFont *font)
Returns the current font style.
To the sge_tt_textout() functions>>

Copyright © 1999-2003 Anders Lindström
Last updated 030803