Defines functions for formatting text. More...
#include <vector>
#include <string>
#include "Math/MathCommon.h"
#include "Graphics/Font.h"
Functions | |
int | FormatText (const char *str, FontRef f, const Rectf &area, std::vector< std::string > &text) |
Formats the given string with respect to a given area and font. | |
int | FormatText (const char *str, FontRef f, std::vector< std::string > &text) |
Formats the given string not taking area into consideration. | |
void | DrawFormattedText (FontRef f, const Point2f &p, const Color4f &c, const std::vector< std::string > &text) |
Draws the given formatted text. | |
void | DrawFormattedText (FontRef f, const Point2f &p, const Color4f &c, const std::vector< std::string > &text, uint offset, uint count) |
Draws a sub-sequance of the given formatted text. | |
int | WrapText (FontRef f, float width, const std::string &str, std::vector< std::string > &txt) |
Wraps text to be within a given max width. | |
int | WrapText (FontRef f, float width, const std::vector< std::string > &words, std::vector< std::string > &txt) |
Wraps a vector of words to be within a given max width. |
Defines functions for formatting text.
Defines functions that format strings given a Font and a description of the bounds that the formatted text should fit into.
void DrawFormattedText | ( | FontRef | f, | |
const Point2f & | p, | |||
const Color4f & | c, | |||
const std::vector< std::string > & | text, | |||
uint | offset, | |||
uint | count | |||
) |
Draws a sub-sequance of the given formatted text.
[in] | f | the font to draw the text with. |
[in] | p | the top left position in normalized devices coordintes where the text will be draw. |
[in] | c | the color to draw the text. |
[in] | text | the text to draw. Assumed to be generated with respect to the font f. |
[in] | offset | the offset from the start of the text vector to draw from. |
[in] | count | the number of lines to draw from the text vector. |
void DrawFormattedText | ( | FontRef | f, | |
const Point2f & | p, | |||
const Color4f & | c, | |||
const std::vector< std::string > & | text | |||
) |
Draws the given formatted text.
[in] | f | the font to draw the text with. |
[in] | p | the top left position in normalized devices coordintes where the text will be draw. |
[in] | c | the color to draw the text. |
[in] | text | the text to draw. Assumed to be generated with respect to the font f. |
int FormatText | ( | const char * | str, | |
FontRef | f, | |||
std::vector< std::string > & | text | |||
) |
Formats the given string not taking area into consideration.
Takes a string and splits it into a number of lines based on the given font. After formatting, the text vector can be drawn from top to bottom with the font f to to produce the correctly formatted block of text.
[in] | str | the string to be formatted. |
[in] | f | the font used for formatting. |
[out] | text | the lines of text split from str. |
int FormatText | ( | const char * | str, | |
FontRef | f, | |||
const Rectf & | area, | |||
std::vector< std::string > & | text | |||
) |
Formats the given string with respect to a given area and font.
Takes a string and splits it into a number of lines based on the given font and desired area. After formatting, the text vector can be drawn from top to bottom with the font f to to produce the correctly formatted block of text.
[in] | str | the string to be formatted. |
[in] | f | the font used for formatting. |
[in] | area | the area the str will be formatted to fit into. NOTE: x and y are ignored. |
[out] | text | the lines of text split from str. |
int WrapText | ( | FontRef | f, | |
float | width, | |||
const std::vector< std::string > & | words, | |||
std::vector< std::string > & | txt | |||
) |
Wraps a vector of words to be within a given max width.
[in] | f | the font used to wrap the text. |
[in] | width | the max width to wrap text against. |
[in] | words | the vector of words to wrap. Assumes spaces are present in the words themselves. |
[out] | txt | vector that holds the wrapped text. Where each line in the vector fits into the given width. |
NOTE: Any special characters (newlines, tab etc.) are ignored.
int WrapText | ( | FontRef | f, | |
float | width, | |||
const std::string & | str, | |||
std::vector< std::string > & | txt | |||
) |
Wraps text to be within a given max width.
[in] | f | the font used to wrap the text. |
[in] | width | the max width to wrap text against. |
[in] | str | the string to wrap. |
[out] | txt | vector that holds the wrapped text. Where each line in the vector fits into the given width. |
NOTE: Any special characters (newlines, tab etc.) are ignored.