Class that encapsulates text rendering functionality for a typeface. More...
Public Member Functions | |
void | load () |
Complete font loading. If you create the font from an XML file, this method is invoked automatically after reading all the required data from the XMLAttributes object. If you create the font manually, it is your responsability to call this function as soon as you set up all the appropiate fields of the Font object. | |
bool | isCodepointAvailable (int cp) |
Return whether this Font can draw the specified code-point. | |
void | drawText (string text, Rect draw_area, float z=1.0, float x_scale=1.0, float y_scale=1.0) |
void | setNativeResolution (Size size) |
Set the native resolution for this Font. | |
void | notifyScreenResolution (Size size) |
Notify the Font of the current (usually new) display resolution. | |
float | getLineSpacing (float y_scale=1.0) |
Return the pixel line spacing value for. | |
float | getFontHeight (float y_scale=1.0) |
return the exact pixel height of the font. | |
float | getTextExtent (string text, float x_scale=1.0) |
Return the pixel width of the specified text if rendered with this Font. | |
int | getCharAtPixel (string text, float pixel, float x_scale=1.0) |
Return the index of the closest text character in String text that corresponds to pixel location pixel if the text were rendered. | |
int | getCharAtPixel (string text, int start_char, float pixel, float x_scale=1.0) |
Return the index of the closest text character in String text, starting at character index start_char, that corresponds to pixel location pixel if the text were to be rendered. | |
int | getFormattedLineCount (string text, Rect format_area, int fmt, float x_scale=1.0) |
Return the number of lines the given text would be formatted to. | |
float | getFormattedTextExtent (string text, Rect format_area, int fmt, float x_scale=1.0) |
Return the horizontal pixel extent given text would be formatted to. | |
void | setDefaultResourceGroup (string resourceGroup) |
Sets the default resource group to be used when loading font data. | |
string | getDefaultResourceGroup () |
Returns the default resource group currently set for Fonts. |
Class that encapsulates text rendering functionality for a typeface.
A Font object is created for each unique typeface required. The Font class provides methods for loading typefaces from various sources, and then for outputting text via the Renderer object.
This class is not specific to any font renderer, it just provides the basic interfaces needed to manage fonts.
bool GUI::Font::isCodepointAvailable | ( | int | cp | ) |
Return whether this Font can draw the specified code-point.
cp | utf32 code point that is the subject of the query. |
void GUI::Font::setNativeResolution | ( | Size | size | ) |
void GUI::Font::notifyScreenResolution | ( | Size | size | ) |
float GUI::Font::getLineSpacing | ( | float | y_scale = 1.0 | ) |
Return the pixel line spacing value for.
y_scale | Scaling factor to be applied to the line spacing, where 1.0f is considered to be 'normal'. |
float GUI::Font::getFontHeight | ( | float | y_scale = 1.0 | ) |
return the exact pixel height of the font.
y_scale | Scaling factor to be applied to the height, where 1.0f is considered to be 'normal'. |
float GUI::Font::getTextExtent | ( | string | text, |
float | x_scale = 1.0 |
||
) |
Return the pixel width of the specified text if rendered with this Font.
text | String object containing the text to return the rendered pixel width for. |
x_scale | Scaling factor to be applied to each glyph's x axis when measuring the extent, where 1.0f is considered to be 'normal'. |
int GUI::Font::getCharAtPixel | ( | string | text, |
float | pixel, | ||
float | x_scale = 1.0 |
||
) |
Return the index of the closest text character in String text that corresponds to pixel location pixel if the text were rendered.
text | String object containing the text. |
pixel | Specifies the (horizontal) pixel offset to return the character index for. |
x_scale | Scaling factor to be applied to each glyph's x axis when measuring the text extent, where 1.0f is considered to be 'normal'. |
int GUI::Font::getCharAtPixel | ( | string | text, |
int | start_char, | ||
float | pixel, | ||
float | x_scale = 1.0 |
||
) |
Return the index of the closest text character in String text, starting at character index start_char, that corresponds to pixel location pixel if the text were to be rendered.
text | String object containing the text. |
start_char | index of the first character to consider. This is the lowest value that will be returned from the call. |
pixel | Specifies the (horizontal) pixel offset to return the character index for. |
x_scale | Scaling factor to be applied to each glyph's x axis when measuring the text extent, where 1.0f is considered to be 'normal'. |
int GUI::Font::getFormattedLineCount | ( | string | text, |
Rect | format_area, | ||
int | fmt, | ||
float | x_scale = 1.0 |
||
) |
Return the number of lines the given text would be formatted to.
Since text formatting can result in multiple lines of text being output, it can be useful to know how many lines would be output without actually rendering the text.
text | String object containing the text to be measured. |
format_area | Rect object describing the area to be used when formatting the text depending upon the option specified in fmt. |
fmt | One of the TextFormatting values specifying the text formatting required. |
x_scale | Scaling factor to be applied to each glyph's x axis, where 1.0f is considered to be 'normal'. |
float GUI::Font::getFormattedTextExtent | ( | string | text, |
Rect | format_area, | ||
int | fmt, | ||
float | x_scale = 1.0 |
||
) |
Return the horizontal pixel extent given text would be formatted to.
The value return by this method is basically the extent of the widest line within the formatted text.
text | String object containing the text to be measured. |
format_area | Rect object describing the area to be used when formatting the text depending upon the option specified in fmt. |
fmt | One of the TextFormatting values specifying the text formatting required. |
x_scale | Scaling factor to be applied to each glyph's x axis, where 1.0f is considered to be 'normal'. |
void GUI::Font::setDefaultResourceGroup | ( | string | resourceGroup | ) |
Sets the default resource group to be used when loading font data.
resourceGroup | String describing the default resource group identifier to be used. |
string GUI::Font::getDefaultResourceGroup | ( | ) |
Returns the default resource group currently set for Fonts.