Function caret_rect_for_run

Source
pub fn caret_rect_for_run(
    content_x: f32,
    content_y: f32,
    run: &EditorTextRun,
    local_byte: usize,
    style: EditorStyle,
) -> Rect
Expand description

Resolves one run-local caret rectangle into screen logical pixels.

local_byte is clamped to shaped UTF-8 length. Coordinates are rounded; width is at least one pixel and height at least px_size + 2.

ยงExamples

use ailloli_ui_editor::{input::caret::caret_rect_for_run, layout::EditorTextRun, EditorStyle};
fn caret(run: &EditorTextRun) {
    let rect = caret_rect_for_run(0.0, 0.0, run, usize::MAX, EditorStyle::default());
    assert!(rect.w >= 1.0);
}