FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    PretextLayout

    struct · ferroui-pretext · v0.5.0

    struct PretextLayout
    

    An isolated preparation session. Replacing a backend affects subsequent preparation; already prepared metrics and shaped objects remain usable.

    View source

    Members

    new

    fn new(factory: Rc<dyn IPretextTextMeasurerFactory>) -> Self
    

    Source

    with_shaper_factory

    fn with_shaper_factory(self: Self, factory: Rc<dyn IPretextTextShaperFactory>) -> Self
    

    Source

    from_factories

    fn from_factories(factories: impl IntoIterator<Item = Rc<dyn IPretextTextMeasurerFactory>>) -> Result<Self, PretextError>
    

    Selects the highest-priority supported registered measurement backend. Equal priorities retain registration order. Reflection is unnecessary.

    Source

    text_measurer_factory

    fn text_measurer_factory(self: &Self) -> Rc<dyn IPretextTextMeasurerFactory>
    

    Source

    text_shaper_factory

    fn text_shaper_factory(self: &Self) -> Result<Rc<dyn IPretextTextShaperFactory>, PretextError>
    

    Source

    set_text_measurer_factory

    fn set_text_measurer_factory(self: &Self, factory: Rc<dyn IPretextTextMeasurerFactory>)
    

    Source

    set_text_shaper_factory

    fn set_text_shaper_factory(self: &Self, factory: Option<Rc<dyn IPretextTextShaperFactory>>)
    

    Source

    clear_cache

    fn clear_cache(self: &Self)
    

    Source

    set_locale

    fn set_locale(self: &Self, locale: Option<&str>)
    

    Source

    locale

    fn locale(self: &Self) -> Option<String>
    

    Source

    layout

    fn layout(prepared: &PreparedText, max_width: f64, line_height: f64) -> LayoutResult
    

    Counts lines without materializing text or allocating line objects.

    Source

    layout_with_lines

    fn layout_with_lines(prepared: &PreparedTextWithSegments, max_width: f64, line_height: f64) -> LayoutLinesResult
    

    Materializes the text and geometry of each line.

    Source

    layout_next_line

    fn layout_next_line(prepared: &PreparedTextWithSegments, start: LayoutCursor, max_width: f64) -> Option<LayoutLine>
    

    Resumes at a segment/grapheme cursor. Every returned line advances the cursor, including when an individual grapheme exceeds the width.

    Source

    layout_next_line_range

    fn layout_next_line_range(prepared: &PreparedTextWithSegments, start: LayoutCursor, max_width: f64) -> Option<LayoutLineRange>
    

    Computes the next line without allocating text.

    Source

    materialize_line_range

    fn materialize_line_range(prepared: &PreparedTextWithSegments, line: &LayoutLineRange) -> LayoutLine
    

    Materializes a previously computed range. The cursor carries enough information to recover discretionary hyphens without hidden walk state.

    Source

    walk_line_ranges

    fn walk_line_ranges(prepared: &PreparedTextWithSegments, max_width: f64, on_line: impl FnMut(LayoutLineRange) -> ()) -> usize
    

    Source

    measure_line_stats

    fn measure_line_stats(prepared: &PreparedTextWithSegments, max_width: f64) -> LineStats
    

    Source

    measure_natural_width

    fn measure_natural_width(prepared: &PreparedTextWithSegments) -> f64
    

    Source

    prepare

    fn prepare(self: &Self, text: &str, font: &str, options: PrepareOptions) -> Result<PreparedText, PretextError>
    

    Measures normalized text once for repeated allocation-free layout.

    Source

    prepare_with_segments

    fn prepare_with_segments(self: &Self, text: &str, font: &str, options: PrepareOptions) -> Result<Rc<PreparedTextWithSegments>, PretextError>
    

    Retains normalized source segments in addition to reusable metrics.

    Source

    profile_prepare

    fn profile_prepare(self: &Self, text: &str, font: &str, options: PrepareOptions, now_ms: impl FnMut() -> f64) -> Result<PrepareProfile, PretextError>
    

    Profiles analysis and measurement using a caller-supplied monotonic clock measured in milliseconds. This works with native clocks and browser performance.now() without introducing a platform dependency.

    Source

    prepare_rich_inline

    fn prepare_rich_inline(self: &Self, items: &[RichInlineItem]) -> Result<Rc<PreparedRichInline>, PretextError>
    

    Source

    layout_next_rich_inline_line_range

    fn layout_next_rich_inline_line_range(prepared: &PreparedRichInline, max_width: f64, start: Option<RichInlineCursor>) -> Option<RichInlineLineRange>
    

    Source

    materialize_rich_inline_line_range

    fn materialize_rich_inline_line_range(prepared: &PreparedRichInline, line: &RichInlineLineRange) -> RichInlineLine
    

    Materialize a range produced from this same prepared flow.

    Panics if a caller fabricates a fragment referencing a missing source item, matching the source's invalid-operation contract for mismatched ranges.

    Source

    walk_rich_inline_line_ranges

    fn walk_rich_inline_line_ranges(prepared: &PreparedRichInline, max_width: f64, on_line: impl FnMut(RichInlineLineRange) -> ()) -> usize
    

    Source

    measure_rich_inline_stats

    fn measure_rich_inline_stats(prepared: &PreparedRichInline, max_width: f64) -> RichInlineStats
    

    Compute metrics without allocating fragment vectors or materialized text.

    Source

    shape_text

    fn shape_text(self: &Self, text: &str, font: &str, options: PretextShapeOptions) -> Result<Rc<PretextShapedRun>, PretextError>
    

    Source

    try_shape_text

    fn try_shape_text(self: &Self, text: &str, font: &str, options: PretextShapeOptions) -> Option<Rc<PretextShapedRun>>
    

    Convenience for hosts that can continue without glyph output. Use Self::shape_text when the precise backend error is needed.

    Source

    shape_prepared_text

    fn shape_prepared_text(self: &Self, prepared: Rc<PreparedTextWithSegments>, options: PretextShapeOptions) -> Result<Rc<PreparedShapedText>, PretextError>
    

    Source

    layout_next_shaped_line

    fn layout_next_shaped_line(prepared: &PreparedShapedText, start: LayoutCursor, max_width: f64) -> Result<Option<ShapedLayoutLine>, PretextError>
    

    Source

    materialize_shaped_line_range

    fn materialize_shaped_line_range(prepared: &PreparedShapedText, line: &LayoutLineRange) -> Result<ShapedLayoutLine, PretextError>
    

    Source

    materialize_shaped_line_range_with_options

    fn materialize_shaped_line_range_with_options(self: &Self, prepared: Rc<PreparedTextWithSegments>, line: &LayoutLineRange, options: PretextShapeOptions) -> Result<ShapedLayoutLine, PretextError>
    

    Convenience overload for callers retaining only their prepared metrics.

    Source

    materialize_shaped_rich_inline_line_range

    fn materialize_shaped_rich_inline_line_range(self: &Self, prepared: &PreparedRichInline, line: &RichInlineLineRange, options: PretextShapeOptions) -> Result<ShapedRichInlineLine, PretextError>
    

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.