weasel API - v0.8.0
    Preparing search index...

    Function caretIndexAt

    • 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).

      Parameters

      • ctx: CanvasRenderingContext2D
      • x: number
      • y: number
      • pose: TextPose

      Returns number