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: FontPrimary 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: f32Pre-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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.