Struct Text

Source
pub struct Text {
    pub text: String,
    pub size: f32,
    pub raster_size: Option<f32>,
    pub line_height: Option<f32>,
    pub padding: Vec2,
    pub color: Srgba,
    pub shadow: Option<(Srgba, Vec2)>,
    pub character_color: Option<Box<dyn Fn(usize, usize, char) -> Srgba>>,
    pub align: TextAlign,
    pub position: TextPosition,
    pub transform: Mat4,
    pub character_transform: Option<Box<dyn Fn(usize, usize, char) -> (Mat4, Mat4)>>,
}
Expand description

Description of how an owned String should be rendered as a text mesh.

Fields§

§text: String

Text to render

§size: f32

Font size used by the resulting mesh

§raster_size: Option<f32>

Font size used for glyph rasterization; when None, Text::size will be used

§line_height: Option<f32>

Line height scaling used by the resulting mesh

§padding: Vec2

Padding used by the resuling mesh

§color: Srgba

Font color used by the resulting mesh

§shadow: Option<(Srgba, Vec2)>

Shadow color and offset user by the resulting mesh

§character_color: Option<Box<dyn Fn(usize, usize, char) -> Srgba>>

Function to generate per-character colors

§align: TextAlign

Alignment used by the resulting mesh.

§position: TextPosition

Position used by the resulting; see TextAlign for how this is computed

§transform: Mat4

Transform used by the resulting mesh

§character_transform: Option<Box<dyn Fn(usize, usize, char) -> (Mat4, Mat4)>>

Function to generate per-character position and vertex transforms

Implementations§

Source§

impl Text

Source

pub fn new<S: Into<String>>(text: S) -> Self

Creates a new text description for the given String.

Source

pub fn size(self, size: f32) -> Self

Specifies the font size used by the resulting mesh.

Source

pub fn raster_size(self, raster_size: f32) -> Self

Specifies the font size used for glyph rasterization; when None, Text::size will be used.

Source

pub fn line_height(self, line_height: f32) -> Self

Specifies the line height scaling used by the resulting mesh.

Source

pub fn padding(self, padding: Vec2) -> Self

Specifies the padding used by the resulting mesh.

Source

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

Specifies the font color used by the resulting mesh.

Source

pub fn shadow(self, color: Srgba, offset: Vec2) -> Self

Specifies the shadow color and offset user by the resulting mesh.

Source

pub fn character_color( self, color: Box<dyn Fn(usize, usize, char) -> Srgba>, ) -> Self

Specifies the function to generate per-character colors.

These colors do overide the color set by Text::color.

Source

pub fn align(self, align: TextAlign) -> Self

Specifies the alignment used by the resulting mesh.

Source

pub fn position(self, position: TextPosition) -> Self

Specifies the position used by the resulting; see TextAlign for how this is computed.

Source

pub fn transform(self, transform: Mat4) -> Self

Specifies the transform used by the resulting mesh.

Source

pub fn character_transform( self, transform: Box<dyn Fn(usize, usize, char) -> (Mat4, Mat4)>, ) -> Self

Specifies the function to generate per-character position and vertex transforms.

Source

pub fn as_ref(&self) -> TextRef<'_>

Creates a TextRef referencing this text’s data.

Trait Implementations§

Source§

impl Default for Text

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Text

§

impl !RefUnwindSafe for Text

§

impl !Send for Text

§

impl !Sync for Text

§

impl Unpin for Text

§

impl !UnwindSafe for Text

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

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.