pub fn shape_visual_items<T: ParsedFontTrait>(
visual_items: &[VisualItem],
font_chain_cache: &HashMap<FontChainKey, FontFallbackChain>,
fc_cache: &FcFontCache,
loaded_fonts: &LoadedFonts<T>,
debug_messages: &mut Option<Vec<LayoutDebugMessage>>,
) -> Result<Vec<ShapedItem>, LayoutError>Expand description
Shape visual items into ShapedItems using pre-loaded fonts.
This function does NOT load any fonts - all fonts must be pre-loaded and passed in.
If a required font is not in loaded_fonts, the text will be skipped with a warning.
Optimization: Inline Run Coalescing
When consecutive text VisualItems share the same layout-affecting properties
(font, size, spacing, etc.) but differ only in rendering properties (color,
background), they are coalesced into a single shaping call. This dramatically
reduces the number of font.shape_text() invocations for syntax-highlighted
code where hundreds of <span> elements use the same monospace font but
different colors. After shaping, the original per-span styles are restored
to each ShapedCluster based on byte-range mapping.