Typedefs | |
typedef TTF_Font | Font |
Enumerations | |
enum | Quality { QUALITY_SOLID = 0, QUALITY_BLEND } |
Quality of font glyph rendering. | |
Functions | |
bool | loadFont (const ustring &path, int size) |
Load a TrueType font. | |
SDL_Surface * | renderGlyph (Uint16 ch, int size, const Color &color, const Quality &quality) |
Draw a single glyph onto a new surface ready for further blitting. | |
int | glyphBase (int y, Uint16 ch, int size) |
Calculates the y-coordinate for a glyph to render correctly on the baseline. | |
bool | discardChar (Uint16 ch) |
Check to see if a character should not be drawn. | |
bool | lineWillBreak (const Point &p, int rightClamp, const ustring &str, int size) |
Check to see if a string is too long for one line. | |
int | drawString (const Point &p, const ustring &str, int size, const Color &color) |
Draw a string on the screen. | |
int | drawString (const Point &p, int delimiter, int rightClamp, const ustring &str, int size, const Color &color) |
Draw a string with clamped restrictions and delimiter. | |
int | drawStringMulticolor (const Point &p, int delimiter, int rightClamp, const ustring &str, int size, const ColorRangeVector &vec) |
Draw a multicolor string. | |
int | drawStringCentered (int y, int delimiter, const ustring &str, int size, const Color &color) |
Draw a string centered on the screen. | |
void | drawStringBlended (const Point &p, const ustring &str, int size, const Color &color) |
Draw a string with nicer quality. | |
int | getWidth (const ustring &str, int size) |
Calculate the width of a string. | |
int | getGlyphWidth (Uint16 ch, int size) |
Calculate the width of a glyph. | |
int | getHeight (int size) |
Calculate the pixel height of a string. | |
Fonts::Font * | queryFont (int size) |
Get a font object from the internal map. | |
void | pushFont (int size, Font *font) |
Add a font to the internal map. | |
void | clearFontStack () |
Clear the font map and free allocated memory. | |
Variables | |
std::map< int, Font * > | g_Fonts |
const Color | COLOR_BLACK (0, 0, 0) |
Predefined black font color. | |
const Color | COLOR_WHITE (255, 255, 255) |
Predefined white font color. | |
const Color | COLOR_GREEN (0, 247, 0) |
Predefined green font color. | |
const Color | COLOR_ORANGE (247, 115, 57) |
Predefined orange font color. | |
const Color | COLOR_BLUE (107, 198, 247) |
Predefined blue font color. | |
const Color | COLOR_YELLOW (229, 204, 148) |
Predefined yellow font color. | |
const int | SIZE_LINE_BREAK = 17 |
The amount of pixels to skip following a line break. | |
const int | SIZE_CHAR_SPACE = 2 |
The amount of pixels to skip following a character. | |
const int | SIZE_WHITESPACE = 10-SIZE_CHAR_SPACE |
The amount of pixels that define the size of a whitespace. | |
static const int | FONT_BUTTON_TEXT = 16 |
Size of font for button text. | |
static const int | FONT_STANDARD = 13 |
Size of font for regular dialogue rendering. | |
static const int | FONT_INFO_PAGE = 11 |
Size of font in the Court Record info pages. | |
const Color | COLOR_BLACK |
Predefined black font color. | |
const Color | COLOR_WHITE |
Predefined white font color. | |
const Color | COLOR_BLUE |
Predefined blue font color. | |
const Color | COLOR_ORANGE |
Predefined orange font color. | |
const Color | COLOR_GREEN |
Predefined green font color. | |
const Color | COLOR_YELLOW |
Predefined yellow font color. | |
std::map< int, Font * > | g_Fonts |
bool Fonts::discardChar | ( | Uint16 | ch | ) |
Check to see if a character should not be drawn.
Certain characters are reserved for internal player operation, and therefore should be culled from a visible string. This function will check the provided character, and then decide if it is indeed one of the reserved characters.
ch | The Unicode character to check |
int Fonts::drawString | ( | const Point & | p, | |
int | delimiter, | |||
int | rightClamp, | |||
const ustring & | str, | |||
int | size, | |||
const Color & | color | |||
) |
Draw a string with clamped restrictions and delimiter.
p | The point at which the string should be drawn | |
delimiter | Index into string at which to stop drawing | |
rightClamp | X-coordinate to limit string drawing | |
str | The string to draw | |
size | The size of the source font | |
color | The color of the string |
Draw a string on the screen.
p | The point at which the string should be drawn | |
str | The string to draw | |
size | The size of the source font | |
color | The string color |
void Fonts::drawStringBlended | ( | const Point & | p, | |
const ustring & | str, | |||
int | size, | |||
const Color & | color | |||
) |
Draw a string with nicer quality.
p | The point at which to draw the string | |
str | The string to draw | |
size | The size of the source font | |
color | The color of the string |
int Fonts::drawStringCentered | ( | int | y, | |
int | delimiter, | |||
const ustring & | str, | |||
int | size, | |||
const Color & | color | |||
) |
Draw a string centered on the screen.
y | The y-coordinate of the string | |
delimiter | Index into string at which to stop drawing | |
str | The string to draw | |
size | The size of the source font | |
color | The color of the string |
int Fonts::drawStringMulticolor | ( | const Point & | p, | |
int | delimiter, | |||
int | rightClamp, | |||
const ustring & | str, | |||
int | size, | |||
const ColorRangeVector & | vec | |||
) |
Draw a multicolor string.
p | The point at which to start drawing | |
delimiter | Index into string at which to stop drawing | |
rightClamp | X-coordinate to limit string drawing | |
str | The string to draw | |
vec | A ColorRangeVector containing color offsets |
int Fonts::getGlyphWidth | ( | Uint16 | ch, | |
int | size | |||
) |
Calculate the width of a glyph.
ch | The Unicode character to test | |
size | The size of the source font |
int Fonts::getHeight | ( | int | size | ) |
Calculate the pixel height of a string.
size | The size of the font to test |
int Fonts::getWidth | ( | const ustring & | str, | |
int | size | |||
) |
Calculate the width of a string.
str | The string to test | |
size | The size of the source font |
int Fonts::glyphBase | ( | int | y, | |
Uint16 | ch, | |||
int | size | |||
) |
Calculates the y-coordinate for a glyph to render correctly on the baseline.
Since certain glyphs are bigger than others, this function computes the correct y-coordinte (based on the provided one) that this glyph should be drawn on, in order for the line of text, as a whole, to be drawn correctly and smoothly.
y | The y-coordinate of the line of text | |
ch | The Unicode character | |
size | The source font size |
bool Fonts::lineWillBreak | ( | const Point & | p, | |
int | rightClamp, | |||
const ustring & | str, | |||
int | size | |||
) |
Check to see if a string is too long for one line.
p | The point at which the string is to be drawn | |
rightClamp | The limit at which the line breaks | |
str | The string to check | |
size | The size of the source font |
bool Fonts::loadFont | ( | const ustring & | path, | |
int | size | |||
) |
Load a TrueType font.
path | Path to font file | |
size | Size of the font |
void Fonts::pushFont | ( | int | size, | |
Font * | font | |||
) |
Add a font to the internal map.
size | The size of this font | |
font | Pointer to allocated font object to add |
Font * Fonts::queryFont | ( | int | size | ) |
Get a font object from the internal map.
size | The size of the font to get |
SDL_Surface * Fonts::renderGlyph | ( | Uint16 | ch, | |
int | size, | |||
const Color & | color, | |||
const Quality & | quality | |||
) |
Draw a single glyph onto a new surface ready for further blitting.
ch | The Unicode character to render | |
size | The size of the source font | |
color | The glyph color | |
quality | The quality of the rendering |