Esc

text_offset_x

procedureextensionexperimentalsince 0.36.1Source
  • macOS: text_offset_x works on macOS
  • Linux: text_offset_x works on Linux
  • Windows: text_offset_x works on Windows
  • Wasm: text_offset_x is not available on Wasm

Caret position in points at a UTF-8 byte boundary, including the pair adjustment to the next glyph. Use the whole line so a caret before V in AV sits where V is drawn, rather than at the unkerned A advance.

Signature

text_offset_x :: (
    text: *Text_System,
    line: string,
    offset: int,
    style: Text_Style
) -> float
Example
ui := headless();
defer free_ui(*ui);
assert(text_offset_x(*ui.text, "abc", 2, .{ size = 10 }) == 12);

See also