Skip to main content

PretextLayout

Struct PretextLayout 

Source
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

Source

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

Source

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

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

pub fn clear_cache(&self)

Source

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

Source

pub fn locale(&self) -> Option<String>

Source§

impl PretextLayout

Source

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

Counts lines without materializing text or allocating line objects.

Source

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

Materializes the text and geometry of each line.

Source

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.

Source

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

Computes the next line without allocating text.

Source

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.

Source

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

Source

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

Source

pub fn measure_natural_width(prepared: &PreparedTextWithSegments) -> f64

Source§

impl PretextLayout

Source

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

Measures normalized text once for repeated allocation-free layout.

Source

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.

Source

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

Source

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

Source

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

Source

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.

Source

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

Source

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

Compute metrics without allocating fragment vectors or materialized text.

Source§

impl PretextLayout

Source

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

Source

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.

Source

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

Source

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

Source

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

Source

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.

Source

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.