Function line_layout

Source
pub fn line_layout(
    text: &str,
    font: FontId,
    px: u16,
    m: &dyn TextMeasure,
) -> LineLayout
Expand description

Measures each Unicode scalar and records its next UTF-8 boundary.

px is a logical-pixel font size forwarded unchanged to m. The generated vectors always start with zero and have text.chars().count() + 1 entries. No kerning or shaping across adjacent characters is performed.

§Examples

use ailloli_ui_core::FontId;
use ailloli_ui_text::{line_layout, ApproxTextMeasure};
let layout = line_layout("éa", FontId::Ui, 10, &ApproxTextMeasure);
assert_eq!(layout.byte_offsets, [0, 2, 3]);
assert_eq!(layout.advances.len(), 3);