sdl_ttf

### Header File

The header file may include additional information sdl_ttf.hrl

### Exports

linkedVersion()

Args: -
Returns: {Major, Minor, Patch}
C-API: const SDL_version * TTF_Linked_Version(void);
Desc:
This function gets the version of the SDL_ttf library.

byteSwappedUNICODE(Int)

Args: Int
Returns: void
C-API: void TTF_ByteSwappedUNICODE(int swapped);
Desc:
This function tells the library whether UNICODE text is generally byteswapped. A UNICODE BOM character in a string will override this setting for the remainder of that string.

init()

Args: -
Returns: Result
C-API: int TTF_Init(void);
Desc:
Initialize the TTF engine. Returns 0 on success, -1 on any error.

openFont(File, PointSize)

Args: File, PointSize
Returns: TTF_Font Ref
C-API: TTF_Font * TTF_OpenFont(const char *file, int ptsize);
Desc:
Open a font file and create a font of the specified point size.

openFontIndex(File, PointSize, Index)

Args: File, PointSize, Index
Returns: TTF_Font Ref
C-API: TTF_Font * TTF_OpenFontIndex(const char *file, int ptsize, long index);
Desc:
Open a font file and create a font of the specified point size. Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size. If the value is too high, the last indexed size will be the default.

openFontRW()

Args: N/A
Returns: N/A
C-API: TTF_Font * TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
Desc:
Not implemented.

openFontIndexRW()

Args: N/A
Returns: N/A
C-API: TTF_Font * TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
Desc:
Not implemented.

getFontStyle(Font)

Args: TTF_Font Ref
Returns: FontStyle
C-API: int TTF_GetFontStyle(TTF_Font *font);
Desc:
Retrieve the font style. This font style is implemented by modifying the font glyphs, and doesn't reflect any inherent properties of the truetype font file.

setFontStyle(Font, FontStyle)

Args: TTF_Font Ref, FontStyle
C-API: void TTF_SetFontStyle(TTF_Font *font, int style);
Desc:
Set the font style. This font style is implemented by modifying the font glyphs, and doesn't reflect any inherent properties of the truetype font file.

fontHeight(Font)

Args: TTF_Font Ref
Returns: FontHeight
C-API: int TTF_FontHeight(TTF_Font *font);
Desc:
Get the total height of the font - usually equal to point size

fontAscent(Font)

Args: TTF_Font Ref
Returns: FontAscent
C-API: int TTF_FontAscent(TTF_Font *font);
Desc:
Get the offset from the baseline to the top of the font This is a positive value, relative to the baseline.

fontDescent(Font)

Args: TTF_Font Ref
Returns: FontDescent
C-API: int TTF_FontDescent(TTF_Font *font);
Desc:
Get the offset from the baseline to the bottom of the font This is a negative value, relative to the baseline.

fontLineSkip(Font)

Args: TTF_Font Ref
Returns: FontLineSkip
C-API: int TTF_FontLineSkip(TTF_Font *font);
Desc:
Get the recommended spacing between lines of text for this font

fontFaces(Font)

Args: TTF_Font Ref
Returns: FontFaces
C-API: long TTF_FontFaces(TTF_Font *font);
Desc:
Get the number of faces of the font

fontFaceIsFixedWidth(Font)

Args: TTF_Font Ref
Returns: IsFixedWidth
C-API: int TTF_FontFaceIsFixedWidth(TTF_Font *font);
Desc:
Test if the current font face of the loaded font is a fixed width font. Fixed width fonts are monospace, meaning every character that exists in the font is the same width, thus you can assume that a rendered string's width is going to be the result of a simple calculation: glyph_width * string_length

fontFaceFamilyName(Font)

Args: TTF_Font Ref
Returns: FaceFamilyName
C-API: char * TTF_FontFaceFamilyName(TTF_Font *font);
Desc:
Get the current font face family name from the loaded font. This function may return a NULL pointer, in which case the information is not available.

fontFaceStyleName(Font)

Args: TTF_Font Ref
Returns: FaceStyleName
C-API: char * TTF_FontFaceStyleName(TTF_Font *font);
Desc:
Get the current font face style name from the loaded font. This function may return a NULL pointer, in which case the information is not available.

glyphMetrics(Font, Ch)

Args: TTF_Font Ref, Ch
Returns: {MinX, MinY, MaxX, MaxY, Advance}
C-API: int TTF_GlyphMetrics(TTF_Font *font, Uint16 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance);
Desc:
Get the metrics (dimensions) of a glyph.

sizeText(Font, Text)

Args: TTF_Font Ref, Text
Returns: {Width, Height}
C-API: int TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
Desc:
Get the dimensions of a rendered string of text.

sizeUTF8(Font, Text)

Args: TTF_Font Ref, Text
Returns: {Width, Height}
C-API: int TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
Desc:
Get the dimensions of a rendered string of text.

sizeUNICODE(Font, Text)

Args: TTF_Font Ref, Text
Returns: {Width, Height}
C-API: int TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
Desc:
Get the dimensions of a rendered string of text.

renderTextSolid(Font, Text, FgColor)

Args: TTF_Font Ref, Text, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg);
Desc:
Create an 8-bit palettized surface and render the given text at the fast quality with the given font and color. The palette has 0 as the colorkey, giving it a transparent background, with 1 as the text color.

renderUTF8Solid(Font, Text, FgColor)

Args: TTF_Font Ref, Text, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderUTF8_Solid(TTF_Font *font, const char *text, SDL_Color fg);
Desc:
Create an 8-bit palettized surface and render the given text at the fast quality with the given font and color. The palette has 0 as the colorkey, giving it a transparent background, with 1 as the text color.

renderUNICODESolid(Font, Text, FgColor)

Args: TTF_Font Ref, Text, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderUNICODE_Solid(TTF_Font *font, const Uint16 *text, SDL_Color fg);
Desc:
Create an 8-bit palettized surface and render the given text at the fast quality with the given font and color. The palette has 0 as the colorkey, giving it a transparent background, with 1 as the text color.

renderGlyphSolid(Font, Glyph, FgColor)

Args: TTF_Font Ref, Glyph, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderGlyph_Solid(TTF_Font *font, Uint16 ch, SDL_Color fg);
Desc:
Create an 8-bit palettized surface and render the given glyph at fast quality with the given font and color. The 0 pixel is the colorkey, giving a transparent background, and the 1 pixel is set to the text color. The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.

renderTextShaded(Font, Text, FgColor, BgColor)

Args: TTF_Font Ref, Text, FgColor, BgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderText_Shaded(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg);
Desc:
Create an 8-bit palettized surface and render the given text at high quality with the given font and colors. The 0 pixel is background, while other pixels have varying degrees of the foreground color.

renderUTF8Shaded(Font, Text, FgColor, BgColor)

Args: TTF_Font Ref, Text, FgColor, BgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderUTF8_Shaded(TTF_Font *font, const char *text, SDL_Color fg, SDL_Color bg);
Desc:
Create an 8-bit palettized surface and render the given text at high quality with the given font and colors. The 0 pixel is background, while other pixels have varying degrees of the foreground color.

renderUNICODEShaded(Font, Text, FgColor, BgColor)

Args: TTF_Font Ref, Text, FgColor, BgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderUNICODE_Shaded(TTF_Font *font, const Uint16 *text, SDL_Color fg, SDL_Color bg);
Desc:
Create an 8-bit palettized surface and render the given text at high quality with the given font and colors. The 0 pixel is background, while other pixels have varying degrees of the foreground color.

renderGlyphShaded(Font, Glyph, FgColor, BgColor)

Args: TTF_Font Ref, Glyph, FgColor, BgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderGlyph_Shaded(TTF_Font *font, Uint16 ch, SDL_Color fg, SDL_Color bg);
Desc:
Create an 8-bit palettized surface and render the given glyph at high quality with the given font and colors. The 0 pixel is background, while other pixels have varying degrees of the foreground color. The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.

renderTextBlended(Font, Text, FgColor)

Args: TTF_Font Ref, Text, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderText_Blended(TTF_Font *font, const char *text, SDL_Color fg);
Desc:
Create a 32-bit ARGB surface and render the given text at high quality, using alpha blending to dither the font with the given color.

renderUTF8Blended(Font, Text, FgColor)

Args: TTF_Font Ref, Text, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderUTF8_Blended(TTF_Font *font, const char *text, SDL_Color fg);
Desc:
Create a 32-bit ARGB surface and render the given text at high quality, using alpha blending to dither the font with the given color.

renderUNICODEBlended(Font, Text, FgColor)

Args: TTF_Font Ref, Text, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderUNICODE_Blended(TTF_Font *font, const Uint16 *text, SDL_Color fg);
Desc:
Create a 32-bit ARGB surface and render the given text at high quality, using alpha blending to dither the font with the given color.

renderGlyphBlended(Font, Glyph, FgColor)

Args: TTF_Font Ref, Glyph, FgColor
Returns: SDL_Surface Ref
C-API: SDL_Surface * TTF_RenderGlyph_Blended(TTF_Font *font, Uint16 ch, SDL_Color fg);
Desc:
Create a 32-bit ARGB surface and render the given glyph at high quality, using alpha blending to dither the font with the given color. The glyph is rendered without any padding or centering in the X direction, and aligned normally in the Y direction.

closeFont(Font)

Args: TTF_Font Ref
Returns: void
C-API: void TTF_CloseFont(TTF_Font *font);
Desc:
Close an opened font file.

quit()

Args: -
Returns: void
C-API: void TTF_Quit(void);
Desc:
De-initialize the TTF engine.

wasInit()

Args: -
Returns: Int
C-API: int TTF_WasInit(void);
Desc:
Check if the TTF engine is initialized.

setError(_Error)

Args: N/A
Returns: N/A
C-API: void TTF_SetError(const char *fmt, ...)
Desc:
Not implemented.

getError()

Args: -
Returns: Error
C-API: char * TTF_GetError()
Desc:
Returns a (string) containing a human readable version or the reason for the last error that occured.