Static helpers for text layout and string manipulation. More...
#include <TextManipulators.h>
Static Public Member Functions | |
| static std::string | wordwrap (const sf::Text &text, float maxwidth) |
Wrap a string to fit within a pixel width, using an existing sf::Text. | |
| static std::string | wordwrap (const std::string &input, const sf::Font &font, unsigned int characterSize, float maxWidth) |
| Wrap a string to fit within a pixel width, given explicit font settings. | |
Static helpers for text layout and string manipulation.
TextManipulators provides the word-wrapping logic used internally by ml::Text when setWordWrap(true) is enabled. Both overloads insert newline characters into the string so that no rendered line exceeds a given pixel width.
Definition at line 39 of file TextManipulators.h.
|
static |
Wrap a string to fit within a pixel width, using an existing sf::Text.
Reads the font and character size from text, then inserts newlines at word boundaries so that no line exceeds maxwidth pixels when rendered with those settings.
| text | An sf::Text whose font and character size define the measurement context. The text's current string is used as the input. |
| maxwidth | Maximum line width in pixels. |
|
static |
Wrap a string to fit within a pixel width, given explicit font settings.
Measures each word using font at characterSize and inserts newlines so that no line exceeds maxWidth pixels.
| input | The string to wrap. |
| font | Font used to measure glyph widths. |
| characterSize | Character size in points used for measurement. |
| maxWidth | Maximum line width in pixels. |