TextBoundsIterator

Returns iterator which you can use to calculate text bounds and advancement. This is usable when you need to do some text layouting with wrapping, to avoid guesswork ("will advancement for this space stay the same?"), and Schlemiel's algorithm. Note that you can copy the returned struct to save iterator state.

You can check if iterator is valid with valid property, put new chars with put method, get current advance with advance property, and current bounds with getBounds(ref float[4] bounds) method.

Don't change font parameters while iterating! Or use restoreFont method.

Constructors

this
this(NVGContext actx, float ax, float ay)

Setups iteration. Takes current font parameters from the given NanoVega context.

Members

Functions

getBounds
void getBounds(float[4] bounds)

Returns current text bounds.

getHBounds
void getHBounds(float xmin, float xmax)

Returns current horizontal text bounds.

getVBounds
void getVBounds(float ymin, float ymax)

Returns current vertical text bounds.

put
void put(const(T)[] str)

Add chars.

reset
void reset(NVGContext actx, float ax, float ay)

Resets iteration. Takes current font parameters from the given NanoVega context.

restart
void restart()

Restart iteration. Will not restore font.

restoreFont
void restoreFont()

Restore font settings for the context.

Properties

advance
float advance [@property getter]

Returns current advance

valid
bool valid [@property getter]

Is this iterator valid?

See Also

Meta