pub struct TextLayoutResult {
pub width: f32,
pub height: f32,
pub line_height: f32,
pub lines: Vec<LineLayout>,
/* private fields */
}Fields§
§width: f32Total width of laid out text
height: f32Total height of laid out text
line_height: f32Height of a single line
lines: Vec<LineLayout>Line layout information
Implementations§
Source§impl TextLayoutResult
impl TextLayoutResult
Sourcepub fn new(text: &str, data: TextLayoutData) -> Self
pub fn new(text: &str, data: TextLayoutData) -> Self
Creates a new layout result with the given glyph positions.
Sourcepub fn get_cursor_x(&self, byte_offset: usize) -> f32
pub fn get_cursor_x(&self, byte_offset: usize) -> f32
Returns X position for cursor at given byte offset. Uses logical byte boundaries, including positions shared by a shaped cluster.
Sourcepub fn get_offset_for_x(&self, x: f32) -> usize
pub fn get_offset_for_x(&self, x: f32) -> usize
Returns byte offset for X position. Uses binary search for monotonic positions and nearest-edge lookup for bidirectional text.
Sourcepub fn is_valid_for(&self, text: &str) -> bool
pub fn is_valid_for(&self, text: &str) -> bool
Checks if this layout result is valid for the given text.
Sourcepub fn glyph_layouts(&self) -> &[GlyphLayout]
pub fn glyph_layouts(&self) -> &[GlyphLayout]
Returns visual glyph boxes emitted by shaping/layout.
Sourcepub fn monospaced(text: &str, char_width: f32, line_height: f32) -> Self
pub fn monospaced(text: &str, char_width: f32, line_height: f32) -> Self
Creates a simple layout for monospaced text (for fallback).
Trait Implementations§
Source§impl Clone for TextLayoutResult
impl Clone for TextLayoutResult
Auto Trait Implementations§
impl Freeze for TextLayoutResult
impl RefUnwindSafe for TextLayoutResult
impl Send for TextLayoutResult
impl Sync for TextLayoutResult
impl Unpin for TextLayoutResult
impl UnsafeUnpin for TextLayoutResult
impl UnwindSafe for TextLayoutResult
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
Converts
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> ⓘ
Converts
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