Function prepare_layout

Source
pub fn prepare_layout(
    engine: &mut ParleyEngine,
    params: TextLayoutParams<'_>,
    face_blobs: &mut HashMap<u64, Arc<[u8]>>,
) -> PreparedTextLayout
Expand description

Builds a Parley layout and glyphs; registers font blobs by face_id.

face_blobs is an append-only caller-owned registry during this call: existing IDs are not replaced, and each newly encountered face receives one reference-counted copy of its complete font bytes. The map has no eviction policy. WrapMode::NoWrap ignores params.max_width; other modes treat it as an optional logical-pixel constraint. Uniform glyph colors are None because painting supplies params.style.color separately.

ยงExamples

use std::collections::HashMap;
use ailloli_ui_core::{Color, FontId, TextStyle};
use ailloli_ui_text::{prepare_layout, ParleyEngine, TextLayoutParams};
#[allow(deprecated)] let mut engine = ParleyEngine::new();
let mut faces = HashMap::new();
let prepared = prepare_layout(
    &mut engine,
    TextLayoutParams::new("render", TextStyle::new(FontId::Mono, 14, Color::WHITE)),
    &mut faces,
);
assert!(!prepared.glyphs().is_empty());
assert!(!faces.is_empty());