pub fn split_runs_at(
runs: &[WordSubRun],
offset: usize,
size_pt: f32,
fallbacks: &[EmbeddedFontId],
) -> Option<(Vec<WordSubRun>, Vec<WordSubRun>)>Expand description
Split shaped runs at a byte offset in their concatenated WordSubRun::text.
Complete runs on either side retain their glyphs and measured advances.
A run crossed by the split is reshaped on both sides with its own font and
the supplied fallback chain, so ligatures and positioning across the cut
are recalculated. Each output run’s cluster offsets remain local to its text.
Use the same size_pt and fallback chain used to produce the input runs.
The offset refers to the runs’ text, which may already have been normalized,
not to the document text before shaping.
Returns None if the offset exceeds the concatenated text length, falls
inside a UTF-8 codepoint, or the accumulated text length overflows.
Empty input accepts only offset zero. Splitting at either end reuses all
runs without shaping. This operation does not insert a hyphen or choose a
line-break opportunity.
§Examples
use mos_fonts::{Base14Font, Font, shape_with_fallback, split_runs_at};
let runs = shape_with_fallback(Font::Base14(Base14Font::Helvetica), &[], 12.0, "hello");
let (left, right) = split_runs_at(&runs, 2, 12.0, &[]).expect("valid split");
assert_eq!(left[0].text, "he");
assert_eq!(right[0].text, "llo");