Struct in ldk_text.h

LDKTextGlyphQuad

typedef struct LDKTextGlyphQuad{
  LDKGlyph const *glyph;
  u32 codepoint;
  u32 page_index;
  float x0;
  float y0;
  float x1;
  float y1;
  float u0;
  float v0;
  float u1;
  float v1;
}LDKTextGlyphQuad;
Struct in ldk_text.h

LDKTextLayoutIterator

typedef struct LDKTextLayoutIterator{
  LDKFontInstance *font;
  char const *cursor;
  char const *end;
  float origin_x;
  float pen_x;
  float pen_y;
  float line_height;
  u32 previous_codepoint;
  bool multiline;
}LDKTextLayoutIterator;
Function in ldk_text.h

ldk_text_layout_begin

Initializes a glyph-layout iterator for a null-terminated UTF-8 string.

LDK_API bool ldk_text_layout_begin(
 LDKTextLayoutIterator *iterator,
 LDKFontInstance *font,
 char const *text,
 float x,
 float y,
 bool multiline
);

Parameters

LDKTextLayoutIterator *iterator
Iterator to initialize.
LDKFontInstance *font
Font instance used for glyph metrics and atlas placement.
char const *text
Null-terminated UTF-8 text.
float x
Horizontal text origin in layout units.
float y
Top text origin in layout units.
bool multiline
Whether newline characters advance to a new line.

Returns

true on success, false for invalid arguments.

Function in ldk_text.h

ldk_text_layout_begin_range

Initializes a glyph-layout iterator for a half-open UTF-8 byte range.

LDK_API bool ldk_text_layout_begin_range(
 LDKTextLayoutIterator *iterator,
 LDKFontInstance *font,
 char const *text_start,
 char const *text_end,
 float x,
 float y,
 bool multiline
);

Parameters

LDKTextLayoutIterator *iterator
Iterator to initialize.
LDKFontInstance *font
Font instance used for glyph metrics and atlas placement.
char const *text_start
First byte included in the range.
char const *text_end
First byte excluded from the range.
float x
Horizontal text origin in layout units.
float y
Top text origin in layout units.
bool multiline
Whether newline characters advance to a new line.

Returns

true on success, false for invalid arguments.

Function in ldk_text.h

ldk_text_layout_next

Produces the next drawable glyph quad from a text layout iterator. Invalid glyphs and glyphs whose atlas page cannot be resolved are skipped. Returned positions use the same layout coordinate system supplied to begin. UVs are normalized atlas coordinates and page_index identifies the atlas page.

LDK_API bool ldk_text_layout_next(
 LDKTextLayoutIterator *iterator,
 LDKTextGlyphQuad *out_quad
);

Parameters

LDKTextLayoutIterator *iterator
Active layout iterator.
LDKTextGlyphQuad *out_quad
Destination glyph quad.

Returns

true when a glyph quad was produced, false when iteration is complete.

Function in ldk_text.h

ldk_text_wrapped_next_line

Finds the next wrapped line within a UTF-8 byte range.

LDK_API bool ldk_text_wrapped_next_line(
 LDKFontInstance *font,
 char const *start,
 char const *text_end,
 float max_width,
 char const **out_line_start,
 char const **out_line_end,
 char const **out_next,
 float *out_width
);

Parameters

LDKFontInstance *font
Font used to measure glyph advances and kerning.
char const *start
Byte from which layout begins.
char const *text_end
Exclusive end of the UTF-8 byte range.
float max_width
Maximum line width. Non-positive values disable wrapping.
char const **out_line_start
Receives the first byte included in the line.
char const **out_line_end
Receives the byte immediately after visible line text.
char const **out_next
Receives the byte from which the following line starts.
float *out_width
Optional measured width of the produced line.

Returns

true when a line was produced, false for invalid or empty input.