Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
font.h File Reference

Jo Engine Simple ASCII Font & print support. More...

Go to the source code of this file.

Data Structures

struct  jo_font

Macros

#define jo_font_printf(F, X, Y, S, ...)
 Print arguments using a specific font (using top-left screen coordinates).
#define jo_font_printf_centered(F, X, Y, S, ...)
 Print arguments using a specific font (using screen center coordinates).

Functions

jo_font * jo_font_load (const char *const sub_dir, const char *const filename, const jo_color transparent_color, const int letter_width, const int letter_height, const int letter_spacing, const char *const mapping)
 Load a font.
void jo_font_print (const jo_font *const font, int x, int y, float scale, char *str)
 Print a string using a specific font (using top-left screen coordinates).
void jo_font_print_centered (const jo_font *const font, int x, int y, float scale, char *str)
 Print a string using a specific font (using screen center coordinates).
void jo_font_free (jo_font *const font)
 Free a font loaded with jo_font_load().

Detailed Description

Jo Engine Simple ASCII Font & print support.

Author
Johannes Fetz
Bug
Some glitch when changing scale in jo_font_printf_centered()

Data Structure Documentation

◆ jo_font

struct jo_font
Data Fields
char end_ascii
short * lookup_table
char spacing
char start_ascii
int z_index

Macro Definition Documentation

◆ jo_font_printf

#define jo_font_printf ( F,
X,
Y,
S,
... )

Print arguments using a specific font (using top-left screen coordinates).

Parameters
FThe font (returned by jo_font_load())
XHorizontal location from the left border of the screen
YVertical location from the top border of the screen
SFont scale

◆ jo_font_printf_centered

#define jo_font_printf_centered ( F,
X,
Y,
S,
... )

Print arguments using a specific font (using screen center coordinates).

Parameters
FThe font (returned by jo_font_load())
XHorizontal location from the center of the screen
YVertical location from the center of the screen
SFont scale

Function Documentation

◆ jo_font_free()

void jo_font_free ( jo_font *const font)

Free a font loaded with jo_font_load().

Parameters
fontThe font (returned by jo_font_load())
Remarks
The sprites of the font are not freed (see jo_sprite_free_from())

◆ jo_font_load()

jo_font * jo_font_load ( const char *const sub_dir,
const char *const filename,
const jo_color transparent_color,
const int letter_width,
const int letter_height,
const int letter_spacing,
const char *const mapping )

Load a font.

Parameters
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "FONT.TGA")
transparent_colorTransparent color (see colors.h). Use JO_COLOR_Transparent by default
letter_widthLetter width (must be a multiple of 8)
letter_heightLetter height
letter_spacingLetter spacing
mappingImage pattern : "0123456789ABCDEFGH..." (use
to go to the next image line)
Returns
Font object

◆ jo_font_print()

void jo_font_print ( const jo_font *const font,
int x,
int y,
float scale,
char * str )

Print a string using a specific font (using top-left screen coordinates).

Parameters
fontThe font (returned by jo_font_load())
xHorizontal location from the left border of the screen
yVertical location from the top border of the screen
scaleFont scale
strThe string

◆ jo_font_print_centered()

void jo_font_print_centered ( const jo_font *const font,
int x,
int y,
float scale,
char * str )

Print a string using a specific font (using screen center coordinates).

Parameters
fontThe font (returned by jo_font_load())
xHorizontal location from the center of the screen
yVertical location from the center of the screen
scaleFont scale
strThe string