GrafX2 2.9.3227
The ultimate 256-color painting program
|
#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"
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... | |
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) |
byte * | Render_text_SFont (const char *str, int font_number, int *width, int *height, T_Palette palette) |
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: More... | |
Variables | |
T_Font * | font_list_start |
Head of the font linked list. More... | |
#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))) |
References T_Font::Is_bitmap, and T_Font::Label.
Referenced by Insert_font().
|
static |
References Compare_fonts(), font_list_start, T_Font::Name, T_Font::Next, NULL, and T_Font::Previous.
Referenced by Add_font().
|
static |
References EXTID, Insert_font(), T_Font::Is_bitmap, T_Font::Is_truetype, T_Font::Label, name, T_Font::Name, and NULL.
Referenced by Init_text().
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().
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().
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().
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().
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().
int TrueType_is_supported | ( | void | ) |
Returns true if text.c was compiled with TrueType support.
Referenced by Button_Stats().
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().
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 | ||
) |
References Back_color, Best_color_perceptual_except(), Font_name(), Fore_color, Get_SDL_Palette(), Main, NULL, T_Document::palette, Remap_general_lowlevel(), Surface_to_bytefield(), and SWAP_BYTES.
Referenced by Render_text().
byte * Render_text_SFont | ( | const char * | str, |
int | font_number, | ||
int * | width, | ||
int * | height, | ||
T_Palette | palette | ||
) |
References Back_color, Font_name(), Free_GFX2_Surface(), GFX2_ERROR, GFX2_Log(), GFX2_WARNING, T_GFX2_Surface::h, Load_surface(), New_GFX2_Surface(), NULL, T_GFX2_Surface::palette, T_GFX2_Surface::pixels, Remap_general_lowlevel(), SFont_FreeFont(), SFont_InitFont(), SFont_TextHeight(), SFont_TextWidth(), SFont_Write(), SWAP_BYTES, SFont_Font::Transparent, Verbose_message(), and T_GFX2_Surface::w.
Referenced by 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:
str | The text to render |
font_number | The index of the font to use. Pass 0 for the first font you declared with Add_font(), 1 for the second etc. |
size | The size in points (unused for bitmap fonts) |
antialias | Boolean, true to use antialiasing in TrueType |
bold | Boolean, true to use bold rendering in TrueType |
italic | Boolean, true to use italic rendering in TrueType |
width | Returns the width of the created brush, in pixels. |
height | Returns the height of the created brush, in pixels. |
palette | Returns 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().
T_Font* font_list_start |
Head of the font linked list.
Referenced by Font_count(), Font_label(), Font_name(), Init_text(), Insert_font(), Render_text(), TrueType_font(), and Uninit_text().