A Pre-formatted piece of text, which may contain multiple fonts and colours. More...
Classes | |
| class | Glyph |
| A positioned glyph. More... | |
| class | Line |
| A line containing a sequence of glyph-runs. More... | |
| class | Run |
| A sequence of glyphs with a common font and colour. More... | |
Public Member Functions | |
| TextLayout () | |
| Creates an empty layout. | |
| TextLayout (const TextLayout &) | |
| TextLayout & | operator= (const TextLayout &) |
| ~TextLayout () | |
| Destructor. | |
| void | createLayout (const AttributedString &text, float maxWidth) |
| Creates a layout from the given attributed string. | |
| void | createLayoutWithBalancedLineLengths (const AttributedString &text, float maxWidth) |
| Creates a layout, attempting to choose a width which results in lines of a similar length. | |
| void | draw (Graphics &g, const Rectangle< float > &area) const |
| Draws the layout within the specified area. | |
| float | getWidth () const noexcept |
| Returns the maximum width of the content. | |
| float | getHeight () const noexcept |
| Returns the maximum height of the content. | |
| int | getNumLines () const noexcept |
| Returns the number of lines in the layout. | |
| Line & | getLine (int index) const |
| Returns one of the lines. | |
| void | addLine (Line *line) |
| Adds a line to the layout. | |
| void | ensureStorageAllocated (int numLinesNeeded) |
| Pre-allocates space for the specified number of lines. | |
A Pre-formatted piece of text, which may contain multiple fonts and colours.
A TextLayout is created from an AttributedString, and once created can be quickly drawn into a Graphics context.
Creates an empty layout.
Having created a TextLayout, you can populate it using createLayout() or createLayoutWithBalancedLineLengths().
| TextLayout::TextLayout | ( | const TextLayout & | ) |
Destructor.
| TextLayout& TextLayout::operator= | ( | const TextLayout & | ) |
| void TextLayout::createLayout | ( | const AttributedString & | text, |
| float | maxWidth | ||
| ) |
Creates a layout from the given attributed string.
This will replace any data that is currently stored in the layout.
| void TextLayout::createLayoutWithBalancedLineLengths | ( | const AttributedString & | text, |
| float | maxWidth | ||
| ) |
Creates a layout, attempting to choose a width which results in lines of a similar length.
This will be slower than the normal createLayout method, but produces a tidier result.
| void TextLayout::draw | ( | Graphics & | g, |
| const Rectangle< float > & | area | ||
| ) | const |
Draws the layout within the specified area.
The position of the text within the rectangle is controlled by the justification flags set in the original AttributedString that was used to create this layout.
| float TextLayout::getWidth | ( | ) | const |
Returns the maximum width of the content.
| float TextLayout::getHeight | ( | ) | const |
Returns the maximum height of the content.
| int TextLayout::getNumLines | ( | ) | const |
Returns the number of lines in the layout.
| Line& TextLayout::getLine | ( | int | index | ) | const |
Returns one of the lines.
| void TextLayout::addLine | ( | Line * | line | ) |
Adds a line to the layout.
The layout will take ownership of this line object and will delete it when it is no longer needed.
| void TextLayout::ensureStorageAllocated | ( | int | numLinesNeeded | ) |
Pre-allocates space for the specified number of lines.