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.
Members
newwith_shaper_factoryfrom_factoriestext_measurer_factorytext_shaper_factoryset_text_measurer_factoryset_text_shaper_factoryclear_cacheset_localelocalelayoutlayout_with_lineslayout_next_linelayout_next_line_rangematerialize_line_rangewalk_line_rangesmeasure_line_statsmeasure_natural_widthprepareprepare_with_segmentsprofile_prepareprepare_rich_inlinelayout_next_rich_inline_line_rangematerialize_rich_inline_line_rangewalk_rich_inline_line_rangesmeasure_rich_inline_statsshape_texttry_shape_textshape_prepared_textlayout_next_shaped_linematerialize_shaped_line_rangematerialize_shaped_line_range_with_optionsmaterialize_shaped_rich_inline_line_range
new
fn new(factory: Rc<dyn IPretextTextMeasurerFactory>) -> Self
with_shaper_factory
fn with_shaper_factory(self: Self, factory: Rc<dyn IPretextTextShaperFactory>) -> Self
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.
text_measurer_factory
fn text_measurer_factory(self: &Self) -> Rc<dyn IPretextTextMeasurerFactory>
text_shaper_factory
fn text_shaper_factory(self: &Self) -> Result<Rc<dyn IPretextTextShaperFactory>, PretextError>
set_text_measurer_factory
fn set_text_measurer_factory(self: &Self, factory: Rc<dyn IPretextTextMeasurerFactory>)
set_text_shaper_factory
fn set_text_shaper_factory(self: &Self, factory: Option<Rc<dyn IPretextTextShaperFactory>>)
clear_cache
fn clear_cache(self: &Self)
set_locale
fn set_locale(self: &Self, locale: Option<&str>)
locale
fn locale(self: &Self) -> Option<String>
layout
fn layout(prepared: &PreparedText, max_width: f64, line_height: f64) -> LayoutResult
Counts lines without materializing text or allocating line objects.
layout_with_lines
fn layout_with_lines(prepared: &PreparedTextWithSegments, max_width: f64, line_height: f64) -> LayoutLinesResult
Materializes the text and geometry of each line.
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.
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.
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.
walk_line_ranges
fn walk_line_ranges(prepared: &PreparedTextWithSegments, max_width: f64, on_line: impl FnMut(LayoutLineRange) -> ()) -> usize
measure_line_stats
fn measure_line_stats(prepared: &PreparedTextWithSegments, max_width: f64) -> LineStats
measure_natural_width
fn measure_natural_width(prepared: &PreparedTextWithSegments) -> f64
prepare
fn prepare(self: &Self, text: &str, font: &str, options: PrepareOptions) -> Result<PreparedText, PretextError>
Measures normalized text once for repeated allocation-free layout.
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.
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.
prepare_rich_inline
fn prepare_rich_inline(self: &Self, items: &[RichInlineItem]) -> Result<Rc<PreparedRichInline>, PretextError>
layout_next_rich_inline_line_range
fn layout_next_rich_inline_line_range(prepared: &PreparedRichInline, max_width: f64, start: Option<RichInlineCursor>) -> Option<RichInlineLineRange>
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.
walk_rich_inline_line_ranges
fn walk_rich_inline_line_ranges(prepared: &PreparedRichInline, max_width: f64, on_line: impl FnMut(RichInlineLineRange) -> ()) -> usize
measure_rich_inline_stats
fn measure_rich_inline_stats(prepared: &PreparedRichInline, max_width: f64) -> RichInlineStats
Compute metrics without allocating fragment vectors or materialized text.
shape_text
fn shape_text(self: &Self, text: &str, font: &str, options: PretextShapeOptions) -> Result<Rc<PretextShapedRun>, PretextError>
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.
shape_prepared_text
fn shape_prepared_text(self: &Self, prepared: Rc<PreparedTextWithSegments>, options: PretextShapeOptions) -> Result<Rc<PreparedShapedText>, PretextError>
layout_next_shaped_line
fn layout_next_shaped_line(prepared: &PreparedShapedText, start: LayoutCursor, max_width: f64) -> Result<Option<ShapedLayoutLine>, PretextError>
materialize_shaped_line_range
fn materialize_shaped_line_range(prepared: &PreparedShapedText, line: &LayoutLineRange) -> Result<ShapedLayoutLine, PretextError>
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.
materialize_shaped_rich_inline_line_range
fn materialize_shaped_rich_inline_line_range(self: &Self, prepared: &PreparedRichInline, line: &RichInlineLineRange, options: PretextShapeOptions) -> Result<ShapedRichInlineLine, PretextError>
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEither
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.