GrafX2 2.9.3227
The ultimate 256-color painting program
text.c File Reference
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <SDL_ttf.h>
#include "struct.h"
#include "global.h"
#include "io.h"
#include "errors.h"
#include "windows.h"
#include "misc.h"
#include "setup.h"
#include "loadsave.h"
#include "SFont.h"
+ Include dependency graph for text.c:

Data Structures

struct  T_Font
 Element of the font linked list. More...
 

Macros

#define EXTID(a, b, c)   ((((a)&255)<<16) | (((b)&255)<<8) | (((c)&255)))
 
#define EXTID4(a, b, c, d)   ((((a)&255)<<24) | (((b)&255)<<16) | (((c)&255)<<8) | (((d)&255)))
 

Functions

static int Compare_fonts (T_Font *font_1, T_Font *font_2)
 
static void Insert_font (T_Font *font)
 
static void Add_font (const char *name, const char *font_name)
 
const char * Font_name (int index)
 Finds the filename of a font declared with Add_font(). More...
 
const char * Font_label (int index)
 Finds a label to display for a font declared with Add_font(). More...
 
int TrueType_font (int index)
 Returns true if the font of this number is TrueType, false if it's a SFont bitmap. More...
 
int Font_count (void)
 Number of fonts declared with a series of Add_font() More...
 
void Init_text (void)
 Initialization of text settings, needs to be called once on program startup. More...
 
int TrueType_is_supported ()
 Returns true if text.c was compiled with TrueType support. More...
 
void Uninit_text (void)
 text settings cleanup. called on program shutdown More...
 
byteRender_text_TTF (const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height, T_Palette palette)
 
byteRender_text_SFont (const char *str, int font_number, int *width, int *height, T_Palette palette)
 
byteRender_text (const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height, T_Palette palette)
 Creates a brush, from the parameters given: More...
 

Variables

T_Fontfont_list_start
 Head of the font linked list. More...
 

Macro Definition Documentation

◆ EXTID

#define EXTID (   a,
  b,
 
)    ((((a)&255)<<16) | (((b)&255)<<8) | (((c)&255)))

◆ EXTID4

#define EXTID4 (   a,
  b,
  c,
 
)    ((((a)&255)<<24) | (((b)&255)<<16) | (((c)&255)<<8) | (((d)&255)))

Function Documentation

◆ Compare_fonts()

static int Compare_fonts ( T_Font font_1,
T_Font font_2 
)
static

References T_Font::Is_bitmap, and T_Font::Label.

Referenced by Insert_font().

◆ Insert_font()

static void Insert_font ( T_Font font)
static

◆ Add_font()

static void Add_font ( const char *  name,
const char *  font_name 
)
static

◆ Font_name()

const char * Font_name ( int  index)

Finds the filename of a font declared with Add_font().

References font_list_start, T_Font::Name, T_Font::Next, and NULL.

Referenced by Render_text_SFont(), and Render_text_TTF().

◆ Font_label()

const char * Font_label ( int  index)

Finds a label to display for a font declared with Add_font().

References font_list_start, T_Font::Label, T_Font::Next, and NULL.

Referenced by Draw_one_font_name().

◆ TrueType_font()

int TrueType_font ( int  index)

Returns true if the font of this number is TrueType, false if it's a SFont bitmap.

References font_list_start, T_Font::Is_truetype, T_Font::Next, and NULL.

Referenced by Button_Text().

◆ Font_count()

int Font_count ( void  )

Number of fonts declared with a series of Add_font()

References font_list_start, T_Font::Next, and NULL.

Referenced by Button_Text().

◆ Init_text()

void Init_text ( void  )

Initialization of text settings, needs to be called once on program startup.

References Add_font(), Config_directory, Data_directory, Filepath_append_to_dir(), font_list_start, FONTS_SUBDIRECTORY, For_each_file(), and NULL.

Referenced by Init_program().

◆ TrueType_is_supported()

int TrueType_is_supported ( void  )

Returns true if text.c was compiled with TrueType support.

Referenced by Button_Stats().

◆ Uninit_text()

void Uninit_text ( void  )

text settings cleanup. called on program shutdown

References font_list_start, T_Font::Name, T_Font::Next, and NULL.

Referenced by Program_shutdown().

◆ Render_text_TTF()

byte * Render_text_TTF ( const char *  str,
int  font_number,
int  size,
int  antialias,
int  bold,
int  italic,
int *  width,
int *  height,
T_Palette  palette 
)

◆ Render_text_SFont()

◆ Render_text()

byte * Render_text ( const char *  str,
int  font_number,
int  size,
int  antialias,
int  bold,
int  italic,
int *  width,
int *  height,
T_Palette  palette 
)

Creates a brush, from the parameters given:

Parameters
strThe text to render
font_numberThe index of the font to use. Pass 0 for the first font you declared with Add_font(), 1 for the second etc.
sizeThe size in points (unused for bitmap fonts)
antialiasBoolean, true to use antialiasing in TrueType
boldBoolean, true to use bold rendering in TrueType
italicBoolean, true to use italic rendering in TrueType
widthReturns the width of the created brush, in pixels.
heightReturns the height of the created brush, in pixels.
paletteReturns the custom palette for the brush. Returns true on success.

References font_list_start, T_Font::Is_truetype, T_Font::Next, NULL, Render_text_SFont(), and Render_text_TTF().

Referenced by Button_Text().

Variable Documentation

◆ font_list_start

T_Font* font_list_start