Struct Layout
pub struct Layout<U = ()>{ /* private fields */ }
dep_fontdue
only.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> Layout<U>
impl<'a, U> Layout<U>
pub 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.
pub fn reset(&mut self, settings: &LayoutSettings)
pub fn reset(&mut self, settings: &LayoutSettings)
Resets the current layout settings and clears all appended text.
pub fn clear(&mut self)
pub fn clear(&mut self)
Keeps current layout settings but clears all appended text.
pub 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.
pub fn append<T>(&mut self, fonts: &[T], style: &TextStyle<'_, U>)
pub fn append<T>(&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.
pub fn glyphs(&'a self) -> &'a Vec<GlyphPosition<U>> ⓘ
pub fn glyphs(&'a self) -> &'a Vec<GlyphPosition<U>> ⓘ
Gets the currently laid out glyphs.
pub fn settings(&self) -> &LayoutSettings
pub fn settings(&self) -> &LayoutSettings
Gets the settings currently being used for layout.
Auto Trait Implementations§
impl<U> Freeze for Layout<U>
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> 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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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