pub struct TextLayout {
pub shaped: ShapedText,
pub align: TextAlign,
pub bounds: (f32, f32),
}Expand description
A shaped text block with alignment and bounds information.
Fields§
§shaped: ShapedTextThe raw shaped text (glyph positions, line metrics).
align: TextAlignRequested alignment.
bounds: (f32, f32)(max_width, max_height) — the layout box dimensions.
Implementations§
Source§impl TextLayout
impl TextLayout
Sourcepub fn new(
pipeline: &mut TextPipeline,
text: &str,
style: &TextStyle,
max_width: f32,
align: TextAlign,
) -> Result<Self, TextError>
pub fn new( pipeline: &mut TextPipeline, text: &str, style: &TextStyle, max_width: f32, align: TextAlign, ) -> Result<Self, TextError>
Sourcepub fn align_glyphs(&self) -> Vec<Vec<GlyphPosition>>
pub fn align_glyphs(&self) -> Vec<Vec<GlyphPosition>>
Apply alignment offsets to glyph positions within bounds.
Returns per-line glyph positions adjusted for the requested alignment.
Sourcepub fn hit_test_fast(&self, x: f32) -> usize
pub fn hit_test_fast(&self, x: f32) -> usize
Fast O(log n) hit-test over a single horizontal sweep using binary search over sorted glyph x-positions.
Returns the glyph index (into the concatenated flat list of all
glyphs across all lines) of the entry whose left edge is closest to x.
This is O(log n) in the total number of glyphs, vs. the O(n) linear
scan in Self::hit_test.
Unlike Self::hit_test this method ignores the y-coordinate and
operates on the full concatenated glyph stream — callers that need
per-line hit-testing should pre-filter by line before calling.
Auto Trait Implementations§
impl Freeze for TextLayout
impl RefUnwindSafe for TextLayout
impl Send for TextLayout
impl Sync for TextLayout
impl Unpin for TextLayout
impl UnsafeUnpin for TextLayout
impl UnwindSafe for TextLayout
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more