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
impl ShapedLineLayout
Sourcepub fn from_run(text: &str, run: &ShapedRun) -> Self
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.
Sourcepub fn from_text(text: &str) -> Self
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.
Sourcepub fn apply_justification(
&mut self,
text: &str,
ratio_fixed: i32,
glue: &GlueSpec,
)
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.
Sourcepub fn apply_tracking(&mut self, tracking_subcell: i32)
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.
Sourcepub fn placements(&self) -> &[CellPlacement]
pub fn placements(&self) -> &[CellPlacement]
The cell placements in order.
Sourcepub fn total_cells(&self) -> usize
pub fn total_cells(&self) -> usize
Total width in cells.
Sourcepub fn subcell_remainder(&self) -> i32
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.
Sourcepub fn cluster_map(&self) -> &ClusterMap
pub fn cluster_map(&self) -> &ClusterMap
The underlying cluster map (for interaction queries).
Sourcepub fn placement_at_cell(&self, cell_x: usize) -> Option<&CellPlacement>
pub fn placement_at_cell(&self, cell_x: usize) -> Option<&CellPlacement>
Get the placement for a cell column.
Sourcepub fn placements_for_grapheme(
&self,
grapheme_index: usize,
) -> Vec<&CellPlacement>
pub fn placements_for_grapheme( &self, grapheme_index: usize, ) -> Vec<&CellPlacement>
Get all placements for a grapheme index.
Sourcepub fn extract_text<'a>(
&self,
source: &'a str,
cell_start: usize,
cell_end: usize,
) -> &'a str
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).
Sourcepub fn has_spacing_deltas(&self) -> bool
pub fn has_spacing_deltas(&self) -> bool
Check if any placement has non-zero spacing deltas.
Trait Implementations§
Source§impl Clone for ShapedLineLayout
impl Clone for ShapedLineLayout
Source§fn clone(&self) -> ShapedLineLayout
fn clone(&self) -> ShapedLineLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more