Map a world-space point inside pose to a character offset into
pose.text (0..text.length). Clicks above the first line clamp to 0;
clicks below the last line clamp to text.length. Within a line, the
caret lands between two glyphs at whichever side of the glyph midpoint
x falls on — the standard "snap caret to nearest character boundary"
rule.
The ctx is used only for measureText; its font is set internally
to match the resolved text style. Pass any 2D context (the same one used
to render is fine).
Map a world-space point inside
poseto a character offset intopose.text(0..text.length). Clicks above the first line clamp to 0; clicks below the last line clamp totext.length. Within a line, the caret lands between two glyphs at whichever side of the glyph midpointxfalls on — the standard "snap caret to nearest character boundary" rule.The
ctxis used only formeasureText; itsfontis set internally to match the resolved text style. Pass any 2D context (the same one used to render is fine).