pub struct PretextLayout { /* private fields */ }Expand description
An isolated preparation session. Replacing a backend affects subsequent preparation; already prepared metrics and shaped objects remain usable.
Implementations§
Source§impl PretextLayout
impl PretextLayout
pub fn new(factory: Rc<dyn IPretextTextMeasurerFactory>) -> Self
pub fn with_shaper_factory( self, factory: Rc<dyn IPretextTextShaperFactory>, ) -> Self
Sourcepub fn from_factories(
factories: impl IntoIterator<Item = Rc<dyn IPretextTextMeasurerFactory>>,
) -> Result<Self, PretextError>
pub 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.
pub fn text_measurer_factory(&self) -> Rc<dyn IPretextTextMeasurerFactory>
pub fn text_shaper_factory( &self, ) -> Result<Rc<dyn IPretextTextShaperFactory>, PretextError>
pub fn set_text_measurer_factory( &self, factory: Rc<dyn IPretextTextMeasurerFactory>, )
pub fn set_text_shaper_factory( &self, factory: Option<Rc<dyn IPretextTextShaperFactory>>, )
pub fn clear_cache(&self)
pub fn set_locale(&self, locale: Option<&str>)
pub fn locale(&self) -> Option<String>
Source§impl PretextLayout
impl PretextLayout
Sourcepub fn layout(
prepared: &PreparedText,
max_width: f64,
line_height: f64,
) -> LayoutResult
pub fn layout( prepared: &PreparedText, max_width: f64, line_height: f64, ) -> LayoutResult
Counts lines without materializing text or allocating line objects.
Sourcepub fn layout_with_lines(
prepared: &PreparedTextWithSegments,
max_width: f64,
line_height: f64,
) -> LayoutLinesResult
pub fn layout_with_lines( prepared: &PreparedTextWithSegments, max_width: f64, line_height: f64, ) -> LayoutLinesResult
Materializes the text and geometry of each line.
Sourcepub fn layout_next_line(
prepared: &PreparedTextWithSegments,
start: LayoutCursor,
max_width: f64,
) -> Option<LayoutLine>
pub 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.
Sourcepub fn layout_next_line_range(
prepared: &PreparedTextWithSegments,
start: LayoutCursor,
max_width: f64,
) -> Option<LayoutLineRange>
pub fn layout_next_line_range( prepared: &PreparedTextWithSegments, start: LayoutCursor, max_width: f64, ) -> Option<LayoutLineRange>
Computes the next line without allocating text.
Sourcepub fn materialize_line_range(
prepared: &PreparedTextWithSegments,
line: &LayoutLineRange,
) -> LayoutLine
pub 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.
pub fn walk_line_ranges( prepared: &PreparedTextWithSegments, max_width: f64, on_line: impl FnMut(LayoutLineRange), ) -> usize
pub fn measure_line_stats( prepared: &PreparedTextWithSegments, max_width: f64, ) -> LineStats
pub fn measure_natural_width(prepared: &PreparedTextWithSegments) -> f64
Source§impl PretextLayout
impl PretextLayout
Sourcepub fn prepare(
&self,
text: &str,
font: &str,
options: PrepareOptions,
) -> Result<PreparedText, PretextError>
pub fn prepare( &self, text: &str, font: &str, options: PrepareOptions, ) -> Result<PreparedText, PretextError>
Measures normalized text once for repeated allocation-free layout.
Sourcepub fn prepare_with_segments(
&self,
text: &str,
font: &str,
options: PrepareOptions,
) -> Result<Rc<PreparedTextWithSegments>, PretextError>
pub fn prepare_with_segments( &self, text: &str, font: &str, options: PrepareOptions, ) -> Result<Rc<PreparedTextWithSegments>, PretextError>
Retains normalized source segments in addition to reusable metrics.
Sourcepub fn profile_prepare(
&self,
text: &str,
font: &str,
options: PrepareOptions,
now_ms: impl FnMut() -> f64,
) -> Result<PrepareProfile, PretextError>
pub fn profile_prepare( &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§impl PretextLayout
impl PretextLayout
pub fn prepare_rich_inline( &self, items: &[RichInlineItem], ) -> Result<Rc<PreparedRichInline>, PretextError>
pub fn layout_next_rich_inline_line_range( prepared: &PreparedRichInline, max_width: f64, start: Option<RichInlineCursor>, ) -> Option<RichInlineLineRange>
Sourcepub fn materialize_rich_inline_line_range(
prepared: &PreparedRichInline,
line: &RichInlineLineRange,
) -> RichInlineLine
pub 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.
pub fn walk_rich_inline_line_ranges( prepared: &PreparedRichInline, max_width: f64, on_line: impl FnMut(RichInlineLineRange), ) -> usize
Sourcepub fn measure_rich_inline_stats(
prepared: &PreparedRichInline,
max_width: f64,
) -> RichInlineStats
pub fn measure_rich_inline_stats( prepared: &PreparedRichInline, max_width: f64, ) -> RichInlineStats
Compute metrics without allocating fragment vectors or materialized text.
Source§impl PretextLayout
impl PretextLayout
pub fn shape_text( &self, text: &str, font: &str, options: PretextShapeOptions, ) -> Result<Rc<PretextShapedRun>, PretextError>
Sourcepub fn try_shape_text(
&self,
text: &str,
font: &str,
options: PretextShapeOptions,
) -> Option<Rc<PretextShapedRun>>
pub fn try_shape_text( &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.
pub fn shape_prepared_text( &self, prepared: Rc<PreparedTextWithSegments>, options: PretextShapeOptions, ) -> Result<Rc<PreparedShapedText>, PretextError>
pub fn layout_next_shaped_line( prepared: &PreparedShapedText, start: LayoutCursor, max_width: f64, ) -> Result<Option<ShapedLayoutLine>, PretextError>
pub fn materialize_shaped_line_range( prepared: &PreparedShapedText, line: &LayoutLineRange, ) -> Result<ShapedLayoutLine, PretextError>
Sourcepub fn materialize_shaped_line_range_with_options(
&self,
prepared: Rc<PreparedTextWithSegments>,
line: &LayoutLineRange,
options: PretextShapeOptions,
) -> Result<ShapedLayoutLine, PretextError>
pub fn materialize_shaped_line_range_with_options( &self, prepared: Rc<PreparedTextWithSegments>, line: &LayoutLineRange, options: PretextShapeOptions, ) -> Result<ShapedLayoutLine, PretextError>
Convenience overload for callers retaining only their prepared metrics.