Struct fontdue::layout::Layout

source ·
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>

source

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.

source

pub fn reset(&mut self, settings: &LayoutSettings)

Resets the current layout settings and clears all appended text.

source

pub fn clear(&mut self)

Keeps current layout settings but clears all appended text.

source

pub fn height(&self) -> f32

Gets the current height of the appended text.

source

pub fn lines(&'a self) -> Option<&'a Vec<LinePosition>>

Gets the currently positioned lines. If there are no lines positioned, this returns none.

source

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.

source

pub fn glyphs(&'a self) -> &'a Vec<GlyphPosition<U>>

Gets the currently laid out glyphs.

source

pub fn settings(&self) -> &LayoutSettings

Gets the settings currently being used for layout.

Auto Trait Implementations§

§

impl<U> RefUnwindSafe for Layout<U>
where U: RefUnwindSafe,

§

impl<U> Send for Layout<U>
where U: Send,

§

impl<U> Sync for Layout<U>
where U: Sync,

§

impl<U> Unpin for Layout<U>
where U: Unpin,

§

impl<U> UnwindSafe for Layout<U>
where U: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.