SDL 2.0
SDL_test_font.h File Reference
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_test_font.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDLTest_TextWindow
 Data used for multi-line text output. More...
 

Macros

#define FONT_CHARACTER_SIZE   8
 
#define FONT_LINE_HEIGHT   (FONT_CHARACTER_SIZE + 2)
 

Functions

int SDLTest_DrawCharacter (SDL_Renderer *renderer, int x, int y, Uint32 c)
 Draw a string in the currently set font.
 
int SDLTest_DrawString (SDL_Renderer *renderer, int x, int y, const char *s)
 Draw a UTF-8 string in the currently set font.
 
SDLTest_TextWindowSDLTest_TextWindowCreate (int x, int y, int w, int h)
 Create a multi-line text output window.
 
void SDLTest_TextWindowDisplay (SDLTest_TextWindow *textwin, SDL_Renderer *renderer)
 Display a multi-line text output window.
 
void SDLTest_TextWindowAddText (SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(2)
 Add text to a multi-line text output window.
 
void SDLTest_TextWindowAddTextWithLength (SDLTest_TextWindow *textwin, const char *text, size_t len)
 Add text to a multi-line text output window.
 
void SDLTest_TextWindowClear (SDLTest_TextWindow *textwin)
 Clear the text in a multi-line text output window.
 
void SDLTest_TextWindowDestroy (SDLTest_TextWindow *textwin)
 Free the storage associated with a multi-line text output window.
 
void SDLTest_CleanupTextDrawing (void)
 Cleanup textures used by font drawing functions.
 

Detailed Description

Include file for SDL test framework.

This code is a part of the SDL2_test library, not the main SDL library.

Definition in file SDL_test_font.h.

Macro Definition Documentation

◆ FONT_CHARACTER_SIZE

#define FONT_CHARACTER_SIZE   8

Definition at line 41 of file SDL_test_font.h.

◆ FONT_LINE_HEIGHT

#define FONT_LINE_HEIGHT   (FONT_CHARACTER_SIZE + 2)

Definition at line 42 of file SDL_test_font.h.

Function Documentation

◆ SDLTest_CleanupTextDrawing()

void SDLTest_CleanupTextDrawing ( void  )

Cleanup textures used by font drawing functions.

◆ SDLTest_DrawCharacter()

int SDLTest_DrawCharacter ( SDL_Renderer renderer,
int  x,
int  y,
Uint32  c 
)

Draw a string in the currently set font.

Parameters
rendererThe renderer to draw on.
xThe X coordinate of the upper left corner of the character.
yThe Y coordinate of the upper left corner of the character.
cThe character to draw.
Returns
0 on success, -1 on failure.

◆ SDLTest_DrawString()

int SDLTest_DrawString ( SDL_Renderer renderer,
int  x,
int  y,
const char *  s 
)

Draw a UTF-8 string in the currently set font.

The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets.

Parameters
rendererThe renderer to draw on.
xThe X coordinate of the upper left corner of the string.
yThe Y coordinate of the upper left corner of the string.
sThe string to draw.
Returns
0 on success, -1 on failure.

◆ SDLTest_TextWindowAddText()

void SDLTest_TextWindowAddText ( SDLTest_TextWindow textwin,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)

Add text to a multi-line text output window.

Adds UTF-8 text to the end of the current text. The newline character starts a new line of text. The backspace character deletes the last character or, if the line is empty, deletes the line and goes to the end of the previous line.

Parameters
textwinThe text output window
fmtA printf() style format string
...additional parameters matching % tokens in the fmt string, if any
Since
This function is available since SDL 2.24.0

◆ SDLTest_TextWindowAddTextWithLength()

void SDLTest_TextWindowAddTextWithLength ( SDLTest_TextWindow textwin,
const char *  text,
size_t  len 
)

Add text to a multi-line text output window.

Adds UTF-8 text to the end of the current text. The newline character starts a new line of text. The backspace character deletes the last character or, if the line is empty, deletes the line and goes to the end of the previous line.

Parameters
textwinThe text output window
textThe text to add to the window
lenThe length, in bytes, of the text to add to the window
Since
This function is available since SDL 2.24.0

◆ SDLTest_TextWindowClear()

void SDLTest_TextWindowClear ( SDLTest_TextWindow textwin)

Clear the text in a multi-line text output window.

Parameters
textwinThe text output window
Since
This function is available since SDL 2.24.0

◆ SDLTest_TextWindowCreate()

SDLTest_TextWindow * SDLTest_TextWindowCreate ( int  x,
int  y,
int  w,
int  h 
)

Create a multi-line text output window.

Parameters
xThe X coordinate of the upper left corner of the window.
yThe Y coordinate of the upper left corner of the window.
wThe width of the window (currently ignored)
hThe height of the window (currently ignored)
Returns
the new window, or NULL on failure.
Since
This function is available since SDL 2.24.0

◆ SDLTest_TextWindowDestroy()

void SDLTest_TextWindowDestroy ( SDLTest_TextWindow textwin)

Free the storage associated with a multi-line text output window.

Parameters
textwinThe text output window
Since
This function is available since SDL 2.24.0

◆ SDLTest_TextWindowDisplay()

void SDLTest_TextWindowDisplay ( SDLTest_TextWindow textwin,
SDL_Renderer renderer 
)

Display a multi-line text output window.

This function should be called every frame to display the text

Parameters
textwinThe text output window
rendererThe renderer to use for display
Since
This function is available since SDL 2.24.0