Fonts Namespace Reference

Namespace for all font and string drawing related API. More...


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


Detailed Description

Namespace for all font and string drawing related API.

Function Documentation

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.

Parameters:
ch The Unicode character to check
Returns:
true if it should be discarded, false otherwise

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.

Parameters:
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
Returns:
Index into the string where drawing stopped

int Fonts::drawString ( const Point p,
const ustring &  str,
int  size,
const Color color 
)

Draw a string on the screen.

Parameters:
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
Returns:
Index into the string where drawing stopped

void Fonts::drawStringBlended ( const Point p,
const ustring &  str,
int  size,
const Color color 
)

Draw a string with nicer quality.

Parameters:
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.

Parameters:
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
Returns:
Index into string at which drawing stopped

int Fonts::drawStringMulticolor ( const Point p,
int  delimiter,
int  rightClamp,
const ustring &  str,
int  size,
const ColorRangeVector &  vec 
)

Draw a multicolor string.

Parameters:
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
Returns:
Index into string where drawing stopped

int Fonts::getGlyphWidth ( Uint16  ch,
int  size 
)

Calculate the width of a glyph.

Parameters:
ch The Unicode character to test
size The size of the source font
Returns:
The pixel width of the glyph

int Fonts::getHeight ( int  size  ) 

Calculate the pixel height of a string.

Parameters:
size The size of the font to test
Returns:
The pixel height of the font

int Fonts::getWidth ( const ustring &  str,
int  size 
)

Calculate the width of a string.

Parameters:
str The string to test
size The size of the source font
Returns:
The calculated pixel string width as if it were drawn on the screen

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.

Parameters:
y The y-coordinate of the line of text
ch The Unicode character
size The source font size
Returns:
The calculated y-coordinate for this glyph

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.

Parameters:
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
Returns:
true if this string exceeds the provided limit, false otherwise

bool Fonts::loadFont ( const ustring &  path,
int  size 
)

Load a TrueType font.

Parameters:
path Path to font file
size Size of the font
Returns:
true if successful, false otherwise

void Fonts::pushFont ( int  size,
Font *  font 
)

Add a font to the internal map.

Parameters:
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.

Parameters:
size The size of the font to get
Returns:
Pointer to requested font object

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.

Parameters:
ch The Unicode character to render
size The size of the source font
color The glyph color
quality The quality of the rendering
Returns:
A new SDL_Surface with the glyph drawn


Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3