Struct fontdue::layout::Layout[][src]

pub struct Layout<U: Copy + Clone = ()> { /* fields omitted */ }
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

impl<'a, U: Copy + Clone> Layout<U>[src]

pub fn new(coordinate_system: CoordinateSystem) -> Layout<U>[src]

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.

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

Resets the current layout settings and clears all appended text.

pub fn clear(&mut self)[src]

Keeps current layout settings but clears all appended text.

pub fn height(&self) -> f32[src]

Gets the current height of the appended text.

pub fn lines(&self) -> usize[src]

Gets the current line count. If there’s no text this still returns 1.

pub fn append<T: Borrow<Font>>(&mut self, fonts: &[T], style: &TextStyle<'_, U>)[src]

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.

pub fn glyphs(&'a mut self) -> &'a Vec<GlyphPosition<U>>[src]

Gets the current laid out glyphs. Additional layout may be performed lazily here.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.