gui2.textbreaker

A struct handling breaking of text into lines.

struct TextBreaker(S) if (isSomeString!(S));

Breaks up a text into lines of specified width.

const pure nothrow const(S[]) lines();

Access lines of broken text.

const pure nothrow const(Vector2u[]) lineSizes();

Access line sizes (in pixels) of lines from the "lines" property.

void parse(const S text, const uint width, Vector2u delegate(S) getTextSize);

Parse and break text into lines.

Parameters:
S text Text to break. The user must ensure that each code point in this string corresponds exactly to 1 character. This is required to avoid allocations using slicing.
uint width Maximum width of a line in pixels. Note that if a single word in text is wider than this, it will not be broken and result in a wider line.
Vector2u delegate(S) getTextSize Delegate that takes a string and returns its size in pixels.