# TrueType font output

- sge_tt_textout
- sge_tt_textoutf

To the TTF setup functions>>

## sge_tt_textout

- SDL_Rect sge_tt_textout(SDL_Surface *Surface, sge_TTFont *font, const char *string, Sint16 x, Sint16 y, Uint32 fcolor, Uint32 bcolor, int Alpha)
- SDL_Rect sge_tt_textout(SDL_Surface *Surface, sge_TTFont *font, const char *string, Sint16 x, Sint16 y, Uint8 fR, Uint8 fG, Uint8 fB, Uint8 bR, Uint8 bG, Uint8 bB, int Alpha)
- SDL_Rect sge_tt_textout_UNI(SDL_Surface *Surface, sge_TTFont *font, const Uint16 *uni, Sint16 x, Sint16 y, Uint32 fcolor, Uint32 bcolor, int Alpha)
- SDL_Rect sge_tt_textout_UNI(SDL_Surface *Surface, sge_TTFont *font, const Uint16 *uni, Sint16 x, Sint16 y, Uint8 fR, Uint8 fG, Uint8 fB, Uint8 bR, Uint8 bG, Uint8 bB, int Alpha)
- SDL_Rect sge_tt_textout_UTF8(SDL_Surface *Surface, sge_TTFont *font, const char *string, Sint16 x, Sint16 y, Uint32 fcolor, Uint32 bcolor, int Alpha)
- SDL_Rect sge_tt_textout_UTF8(SDL_Surface *Surface, sge_TTFont *font, const char *string, Sint16 x, Sint16 y, Uint8 fR, Uint8 fG, Uint8 fB, Uint8 bR, Uint8 bG, Uint8 bB, int Alpha)

Renders the given Latin-1/Unicode/UTF-8 string on surface with the given font.
SDL_Surface *Surface - The surface to render text to.
sge_TTFont *font - The font to render the text with.
const char *string or const Uint16 *uni - The Latin-1/Unicode/UTF-8 text string.
Sint16 x, Sint16 y - The leftmost point of the baseline for the text.
Uint32 fcolor or Uint8 fR, Uint8 fG, Uint8 fB - The color of the font.
Uint32 bcolor or Uint8 bR, Uint8 bG, Uint8 bB - The background color (see below).
int Alpha - Sets the transparency of the text (0-255).
You can use sge_TTF_AAOn(), sge_TTF_AAOff() and sge_TTF_AA_Alpha() to control how the text is rendered. If you use antialiasing, the background color must be set to the background color of the area where you will render the text. If the background has more than one color it might be better to use sge_TTF_AA_Alpha().
Does lock and update the surface. Does respect clipping.
Returns SDL_Rect: The size and position of the rendered text.

## sge_tt_textoutf

- SDL_Rect sge_tt_textoutf(SDL_Surface *Surface, sge_TTFont *font, Sint16 x, Sint16 y, Uint8 fR, Uint8 fG, Uint8 fB, Uint8 bR, Uint8 bG, Uint8 bB, int Alpha, char *format,...)

Just as sge_tt_textout() but with the same syntax as printf().

### Example

#include <iostream>
#include <string>
#include "SDL.h"
#include "sge.h"
using namespace std;
...

//Init font engine and exit on error
if(sge_TTF_Init()!=0){
  cerr << "TT error: " << SDL_GetError() << endl;
  exit(1);
}

//Open font and exit on error
sge_TTFont *font=sge_TTF_OpenFont("font.ttf", 25);
if(!font){
  cerr << "TT error: " << SDL_GetError() << endl;
  exit(1);
}

string text("Hello World!");
sge_tt_textoutf( screen, font, 10,100, 0,200,100, 0,0,0, SDL_ALPHA_OPAQUE, "Testing: %s", text.c_str() );
sge_TTF_CloseFont(font);
To the TTF input functions>>

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