Skip to main content

ShapedSegment

Struct ShapedSegment 

Source
pub struct ShapedSegment {
    pub font_id: u64,
    pub font_data: Arc<Vec<u8>>,
    pub font_index: u32,
    pub normalized_coords: Vec<i16>,
    pub level: u8,
    pub glyphs: Vec<GlyphPosition>,
    pub width: f32,
}
Expand description

One maximal (font_id, BiDi level) slice within a shaped run.

Emitted in logical source order so callers can walk the segment list and snap selection ranges at boundaries. Each segment’s glyphs are still in cosmic-text’s visual order - the renderer paints them in that order, while caret/selection math uses GlyphPosition::byte_start / GlyphPosition::byte_end to map back to logical bytes.

Fields§

§font_id: u64

Opaque font identifier from the shaper’s font database. Two segments with the same font_id resolve through the same font_data so the renderer can cache by id.

§font_data: Arc<Vec<u8>>

TTF/OTF bytes of the resolved face for this segment.

§font_index: u32

Face index inside the font file.

§normalized_coords: Vec<i16>

Normalized variation coordinates of the instance this segment was shaped at, in the face’s axis order, as F2Dot14 raw bits. Empty for a static face, which has one instance and needs none.

A variable face shapes at the instance the authored font-weight selects, and the advances in glyphs come from that instance. The renderer hands these coordinates to the glyph rasterizer so the outlines it paints belong to the same one; without them the outlines come from the face’s default instance and the text pairs one weight’s spacing with another weight’s strokes.

§level: u8

BiDi embedding level (Unicode BiDi algorithm). Even = LTR, odd = RTL. From cosmic-text’s LayoutGlyph.level (unicode-bidi crate).

§glyphs: Vec<GlyphPosition>

Glyphs belonging to this segment, in cosmic-text’s visual order. The renderer issues one draw_glyphs(&font_data) per segment.

§width: f32

Total visual advance of this segment in logical pixels.

Implementations§

Source§

impl ShapedSegment

Source

pub const fn is_ltr(&self) -> bool

Convenience: even-level = LTR.

Source

pub const fn is_rtl(&self) -> bool

Convenience: odd-level = RTL.

Trait Implementations§

Source§

impl Clone for ShapedSegment

Source§

fn clone(&self) -> ShapedSegment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ShapedSegment

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, 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.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
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.
§

impl<T> ConditionalSend for T
where T: Send,