Skip to main content

Word

Struct Word 

Source
pub(crate) struct Word {
    pub(crate) text: String,
    pub(crate) actual_text: Option<String>,
    pub(crate) font: Font,
    pub(crate) size_pt: f32,
    pub(crate) width_pt: f32,
    pub(crate) subruns: Vec<WordSubRun>,
    pub(crate) shy_break_offsets: Vec<usize>,
}

Fields§

§text: String§actual_text: Option<String>§font: Font

Primary face – the style-resolved choice from the active FontFamily (regular/bold/italic/monospace). Used for line metrics (ascent/descent), inter-word spacing, and character-wise hyphenation width estimates. Per-glyph fallback faces (e.g. Noto Sans Math for <=) live inside Word::subruns.

§size_pt: f32§width_pt: f32

Pre-computed advance width – populated when the word is constructed in collect_words (sum of subruns[i].advance_pt) so the line-breaker doesn’t re-measure on every comparison.

§subruns: Vec<WordSubRun>

Per-glyph-fallback sub-runs produced by shape_with_fallback. One sub-run per contiguous source span that shares a face; each carries its own font + text slice + glyph stream with cluster offsets rebased to its local text. flush_line emits one crate::TextRun per sub-run, advancing the x cursor by subrun.advance_pt between them. For Base14 primary faces the result is always a single sub-run with empty glyphs (no fallback target – Base14 emit path uses WinAnsi-byte strings instead).

§shy_break_offsets: Vec<usize>

Byte offsets into text where the source contained a U+00AD soft hyphen. The SHY codepoints are stripped before shaping (split_soft_hyphens in the layout crate); these offsets mark the cluster boundaries where the author permits a line break. The greedy breaker consults them via try_shy_break when a word would otherwise overflow the line: the chosen prefix gets a visible - appended and the suffix continues as the next word. The Knuth-Plass cutover will use the same offsets as flagged Penalty(50) items for optimal (non-greedy) selection.

Trait Implementations§

Source§

impl Clone for Word

Source§

fn clone(&self) -> Word

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 Word

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Word

§

impl RefUnwindSafe for Word

§

impl Send for Word

§

impl Sync for Word

§

impl Unpin for Word

§

impl UnsafeUnpin for Word

§

impl UnwindSafe for Word

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.

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
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

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.