Skip to main content

TextStyle

Struct TextStyle 

Source
pub struct TextStyle {
    pub font_family: Option<String>,
    pub font_size: f32,
    pub color: Rgba,
    pub line_height: f32,
    pub align: TextAlign,
    pub max_width: f32,
    pub position: Vec2,
    pub anchor: Vec2,
    pub outline: Option<TextOutline>,
    pub background: Option<TextBackground>,
}
Expand description

How text looks and where it lies: a caption track’s cues, or a text crate::Generator.

Sizes are resolution-independent: the font size is a fraction of the canvas height, the wrapping width a fraction of the canvas width, and the outline and background padding fractions of the font size. The engine draws with the fonts its host registered: those of font_family first, then the rest in their fallback order.

Fields§

§font_family: Option<String>

The family the text draws in, as the font’s own name table gives it (typographic family, else family), matched without regard to ASCII case. Glyphs its fonts lack, and a family no registered font has, draw from the other fonts in fallback order. None draws from the fallback order alone. Non-empty, at most MAX_FONT_FAMILY_BYTES bytes.

§font_size: f32

Font size as a fraction of the canvas height: positive, at most crate::MAX_CAPTION_FONT_SIZE on a caption track and MAX_TEXT_GENERATOR_FONT_SIZE in a text generator.

§color: Rgba

Text color.

§line_height: f32

Baseline-to-baseline distance in font sizes, in [0.5, 3].

§align: TextAlign

How lines align within the text.

§max_width: f32

Width text wraps at, as a fraction of the canvas width, in (0, 1].

§position: Vec2

Where on the canvas the text’s anchor lies, (0, 0) top-left to (1, 1) bottom-right.

§anchor: Vec2

The point of the text, background included, placed at position: (0.5, 1) is its bottom centre.

§outline: Option<TextOutline>

A band around the glyphs.

§background: Option<TextBackground>

A box behind each line.

Trait Implementations§

Source§

impl Clone for TextStyle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TextStyle

Source§

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

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

impl Default for TextStyle

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for TextStyle

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TextStyle

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for TextStyle

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TextStyle

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.