Struct TextFormat

Source
pub struct TextFormat<S>
where S: Scalar,
{ pub font_size: u32, pub just: Justification, pub line_spacing: S, pub first_line_indent: usize, pub lines_indent: usize, pub color: Color, pub resize: Resize, }
Expand description

A format for some text

Fields§

§font_size: u32

The font size

§just: Justification

The horizantal justification

§line_spacing: S

The spacing between lines. This should usually be somewhere between 1.0 and 2.0, but any scalar is valid

§first_line_indent: usize

The number of spaces to indent the first line of a paragraph

§lines_indent: usize

The number of spaces to indent all lines of a paragraph after the first

§color: Color

The color of the text

§resize: Resize

The resize strategy

Implementations§

Source§

impl<S> TextFormat<S>
where S: Scalar,

Source

pub fn new(font_size: u32) -> TextFormat<S>

Create a default TextFormat with the given font size

Source

pub fn left(self) -> Self

Align the TextFormat to the left

Source

pub fn centered(self) -> Self

Center-align the TextFormat

Source

pub fn right(self) -> Self

Align the TextFormat to the right

Source

pub fn font_size(self, font_size: u32) -> Self

Set the font size

Source

pub fn line_spacing(self, line_spacing: S) -> Self

Set the line spacing

Source

pub fn map_line_spacing<U>(&self) -> TextFormat<U>
where U: Scalar + From<S>,

Changes the type of the line spacing and thus the TextFormat itself

Source

pub fn first_line_indent(self, first_line_indent: usize) -> Self

Set the indentation of the first line

Source

pub fn lines_indent(self, lines_indent: usize) -> Self

Set the indentation of all lines after the first

Source

pub fn color(self, color: Color) -> Self

Set the color

Source

pub fn resize(self, resize: Resize) -> Self

Set the resize strategy

Source

pub fn resize_font(self, max_size: u32) -> Self

Change the font size depending on the the resize strategy

The given max size is not used if the strategy is Resize::None

Trait Implementations§

Source§

impl<S> Clone for TextFormat<S>
where S: Scalar + Clone,

Source§

fn clone(&self) -> TextFormat<S>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for TextFormat<S>
where S: Scalar + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S> From<u32> for TextFormat<S>
where S: Scalar,

Source§

fn from(font_size: u32) -> Self

Converts to this type from the input type.
Source§

impl<S> PartialEq for TextFormat<S>
where S: Scalar + PartialEq,

Source§

fn eq(&self, other: &TextFormat<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> PartialOrd for TextFormat<S>
where S: Scalar + PartialOrd,

Source§

fn partial_cmp(&self, other: &TextFormat<S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S> Copy for TextFormat<S>
where S: Scalar + Copy,

Source§

impl<S> StructuralPartialEq for TextFormat<S>
where S: Scalar,

Auto Trait Implementations§

§

impl<S> Freeze for TextFormat<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for TextFormat<S>
where S: RefUnwindSafe,

§

impl<S> Send for TextFormat<S>
where S: Send,

§

impl<S> Sync for TextFormat<S>
where S: Sync,

§

impl<S> Unpin for TextFormat<S>
where S: Unpin,

§

impl<S> UnwindSafe for TextFormat<S>
where S: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.