FormattedText.h File Reference

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.

Detailed Description

Defines functions for formatting text.

Author:
Joe Forte
Date:
6/7/2008

Defines functions that format strings given a Font and a description of the bounds that the formatted text should fit into.


Function Documentation

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.

Parameters:
[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.
See also:
FormatText
void DrawFormattedText ( FontRef  f,
const Point2f p,
const Color4f c,
const std::vector< std::string > &  text 
)

Draws the given formatted text.

Parameters:
[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.
See also:
FormatText
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.

Parameters:
[in] str the string to be formatted.
[in] f the font used for formatting.
[out] text the lines of text split from str.
Returns:
the number of lines added to text.
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.

Parameters:
[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.
Returns:
the number of lines added to text.
Todo:
take area into consideration.
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.

Parameters:
[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.
Returns:
The number of lines added to the txt vector.
See also:
Split

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.

Parameters:
[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.
Returns:
The number of lines added to the txt vector.

NOTE: Any special characters (newlines, tab etc.) are ignored.

Generated on Mon Apr 5 19:08:04 2010 for BrickOut |ReDuX| by  doxygen 1.6.3