pub struct TextRef<'a> {
    pub text: &'a str,
    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<&'a dyn Fn(usize, usize, char) -> Srgba>,
    pub align: TextAlign,
    pub position: TextPosition,
    pub transform: Mat4,
    pub character_transform: Option<&'a dyn Fn(usize, usize, char) -> (Mat4, Mat4)>,
}
Expand description

Description of how a string slice should be rendered as a text mesh.

Fields§

§text: &'a str

Text to render

§size: f32

Font size used by the resulting mesh

§raster_size: Option<f32>

Font size used for glyph rasterization; when None, TextRef::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<&'a 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<&'a dyn Fn(usize, usize, char) -> (Mat4, Mat4)>

Function to generate per-character position and vertex transforms

Implementations§

source§

impl<'a> TextRef<'a>

source

pub fn new(text: &'a str) -> Self

Creates a new text description for the given string slice.

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, TextRef::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: &'a dyn Fn(usize, usize, char) -> Srgba ) -> Self

Specifies the function to generate per-character colors.

These colors do overide the color set by TextRef::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: &'a dyn Fn(usize, usize, char) -> (Mat4, Mat4) ) -> Self

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

Trait Implementations§

source§

impl<'a> Default for TextRef<'a>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TextRef<'a>

§

impl<'a> !Send for TextRef<'a>

§

impl<'a> !Sync for TextRef<'a>

§

impl<'a> Unpin for TextRef<'a>

§

impl<'a> !UnwindSafe for TextRef<'a>

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.