Skip to main content

ShapedLineLayout

Struct ShapedLineLayout 

Source
pub struct ShapedLineLayout { /* private fields */ }
Expand description

A line of shaped text ready for rendering.

Contains cell placements with spacing deltas, plus metadata for cursor/selection overlay computation. Deterministic: the same input always produces the same layout.

Implementations§

Source§

impl ShapedLineLayout

Source

pub fn from_run(text: &str, run: &ShapedRun) -> Self

Build a layout from a shaped run and its source text.

Uses the ClusterMap to map glyph clusters to cell positions, and extracts spacing deltas from glyph advance differences.

Source

pub fn from_text(text: &str) -> Self

Build a layout from plain text (no shaping, terminal mode).

Equivalent to shaping with NoopShaper — each grapheme maps to cells based on display width, with no spacing deltas.

Source

pub fn apply_justification( &mut self, text: &str, ratio_fixed: i32, glue: &GlueSpec, )

Apply justification spacing to inter-word gaps.

ratio_fixed is in 1/256 sub-cell units (positive = stretch, negative = shrink). Space characters get their glue adjusted according to the ratio.

Source

pub fn apply_tracking(&mut self, tracking_subcell: i32)

Apply uniform letter-spacing (tracking) to all inter-cluster gaps.

tracking_subcell is in 1/256 cell units. Positive = expand, negative = tighten. The last cluster does not get trailing space.

Source

pub fn placements(&self) -> &[CellPlacement]

The cell placements in order.

Source

pub fn total_cells(&self) -> usize

Total width in cells.

Source

pub fn subcell_remainder(&self) -> i32

Accumulated sub-cell remainder from all spacing deltas.

Terminal renderers can ignore this. Web/GPU renderers can use it for sub-pixel positioning of subsequent content.

Source

pub fn cluster_map(&self) -> &ClusterMap

The underlying cluster map (for interaction queries).

Source

pub fn is_empty(&self) -> bool

Whether the layout is empty.

Source

pub fn placement_at_cell(&self, cell_x: usize) -> Option<&CellPlacement>

Get the placement for a cell column.

Source

pub fn placements_for_grapheme( &self, grapheme_index: usize, ) -> Vec<&CellPlacement>

Get all placements for a grapheme index.

Source

pub fn extract_text<'a>( &self, source: &'a str, cell_start: usize, cell_end: usize, ) -> &'a str

Extract the source text for a cell range (delegates to ClusterMap).

Source

pub fn has_spacing_deltas(&self) -> bool

Check if any placement has non-zero spacing deltas.

Trait Implementations§

Source§

impl Clone for ShapedLineLayout

Source§

fn clone(&self) -> ShapedLineLayout

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShapedLineLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more