pub struct Layout<U: Copy + Clone = ()> { /* private fields */ }
Expand description
Text layout requires a small amount of heap usage which is contained in the Layout struct. This context is reused between layout calls. Reusing the Layout struct will greatly reduce memory allocations and is advisable for performance.
Implementations§
source§impl<'a, U: Copy + Clone> Layout<U>
impl<'a, U: Copy + Clone> Layout<U>
sourcepub fn new(coordinate_system: CoordinateSystem) -> Layout<U>
pub fn new(coordinate_system: CoordinateSystem) -> Layout<U>
Creates a layout instance. This requires the direction that the Y coordinate increases in. Layout needs to be aware of your coordinate system to place the glyphs correctly.
sourcepub fn reset(&mut self, settings: &LayoutSettings)
pub fn reset(&mut self, settings: &LayoutSettings)
Resets the current layout settings and clears all appended text.
sourcepub fn lines(&'a self) -> Option<&'a Vec<LinePosition>>
pub fn lines(&'a self) -> Option<&'a Vec<LinePosition>>
Gets the currently positioned lines. If there are no lines positioned, this returns none.
sourcepub fn append<T: Borrow<Font>>(&mut self, fonts: &[T], style: &TextStyle<'_, U>)
pub fn append<T: Borrow<Font>>(&mut self, fonts: &[T], style: &TextStyle<'_, U>)
Performs layout for text horizontally, and wrapping vertically. This makes a best effort attempt at laying out the text defined in the given styles with the provided layout settings. Text may overflow out of the bounds defined in the layout settings and it’s up to the application to decide how to deal with this.
Characters from the input string can only be omitted from the output, they are never reordered. The output buffer will always contain characters in the order they were defined in the styles.
sourcepub fn glyphs(&'a self) -> &'a Vec<GlyphPosition<U>>
pub fn glyphs(&'a self) -> &'a Vec<GlyphPosition<U>>
Gets the currently laid out glyphs.
sourcepub fn settings(&self) -> &LayoutSettings
pub fn settings(&self) -> &LayoutSettings
Gets the settings currently being used for layout.