pub struct TextLayout<'a> {
line: &'a Line,
rect: Rect,
h_align: HAlign,
v_align: VAlign,
}Expand description
Builder for laying out a Line within a bounded Rect.
Call measure to get TextMetrics without
touching any terminal, or render to write directly
into a Terminal.
§Example
use retroglyph::layout::{TextLayout, HAlign, VAlign};
use retroglyph::grid::Rect;
use retroglyph::text::Line;
let rect = Rect::new(0, 0, 20, 5);
let line = Line::raw("Hello, world!");
let metrics = TextLayout::new(&line)
.rect(rect)
.h_align(HAlign::Center)
.measure();
assert_eq!(metrics.height, 1);Fields§
§line: &'a Line§rect: Rect§h_align: HAlign§v_align: VAlignImplementations§
Source§impl<'a> TextLayout<'a>
impl<'a> TextLayout<'a>
Sourcepub fn measure(&self) -> TextMetrics
pub fn measure(&self) -> TextMetrics
Measures the text without rendering, returning its TextMetrics.
Uses the rect’s width for word-wrapping; ignores height.
Auto Trait Implementations§
impl<'a> Freeze for TextLayout<'a>
impl<'a> RefUnwindSafe for TextLayout<'a>
impl<'a> Send for TextLayout<'a>
impl<'a> Sync for TextLayout<'a>
impl<'a> Unpin for TextLayout<'a>
impl<'a> UnsafeUnpin for TextLayout<'a>
impl<'a> UnwindSafe for TextLayout<'a>
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