std1.0.0-beta-7 SafeC docs

std :: gui::gui_text

Struct std::GuiTextLayout

#include <std/gui/gui_text.h> source

struct GuiTextLayout {
    struct Vec<struct GuiTextGlyph> glyphs;
    struct Vec<struct GuiTextLine> lines;
    const ?&GuiTypeface face;
    float size;
    float width;
    float height;
    float lineHeight;
    float ascent;
    float maxWidth;
    unsigned long textLen;
}

Text broken into lines and positioned: word wrap at spaces and hyphens (anywhere for CJK, and inside words too long for a line), hard breaks at '\n', tabs to 4-space stops, alignment within maxWidth. Also maps between positions and byte offsets for carets/selection.

Fields

§struct Vec<struct GuiTextGlyph> glyphssource
§struct Vec<struct GuiTextLine> linessource
§const ?&GuiTypeface facesource
§float sizesource
§float widthsource

widest line

§float heightsource

lines * lineHeight

§float lineHeightsource
§float ascentsource
§float maxWidthsource

as given (0 = no wrapping)

§unsigned long textLensource

Methods

§static struct GuiTextLayout new()source · definition
§void build( const &GuiTypeface face, float size, []const char text, float maxWidth, int align, )source · definition

(Re)builds the layout of text[0..len) — 'len' may be (unsigned long)-1 for a NUL-terminated string. maxWidth <= 0: no wrapping. align: GUI_TEXT_LEFT/CENTER/RIGHT within maxWidth (or the widest line).

§unsigned long hit_test(float x, float y) constsource · definition

The byte offset whose caret position is nearest (x, y) (layout coordinates).

§void caret(unsigned long pos, &float x, &float top, &float height) constsource · definition

The caret's position for byte offset 'pos': x, the line's top, its height.

§unsigned long line_of(unsigned long pos) constsource · definition

The line holding byte offset 'pos'.

§void drop()source · definition
§void free() consumesource · definition

= drop()