Skip to main content

TextStyle

Struct TextStyle 

Source
pub struct TextStyle {
    pub font_size: Option<f32>,
    pub font_weight: u16,
    pub italic: bool,
    pub color: Option<[u8; 4]>,
    pub line_height: Option<f32>,
    pub letter_spacing: f32,
    pub underline: bool,
    pub strikethrough: bool,
}
Expand description

Text rendering style for labels and headings.

All fields have sensible defaults (400-weight, upright, theme colour). Use the builder methods to produce variant styles without repeating boilerplate.

§Example

use oxiui_core::TextStyle;

let style = TextStyle::default()
    .with_size(18.0)
    .with_weight(600)
    .with_color([0, 0, 0, 255]);

Fields§

§font_size: Option<f32>

Font size in points (None = use the theme default).

§font_weight: u16

Font weight: 100 = thin, 400 = regular, 700 = bold, 900 = black.

§italic: bool

Whether the text is rendered with an italic face.

§color: Option<[u8; 4]>

Text colour in RGBA bytes (None = use the theme default).

§line_height: Option<f32>

Line height multiplier (None = platform/theme default of ~1.2).

§letter_spacing: f32

Additional horizontal space between glyphs, in pixels (0.0 = default).

§underline: bool

Draw a line beneath the text.

§strikethrough: bool

Draw a line through the middle of the text.

Implementations§

Source§

impl TextStyle

Source

pub fn bold() -> Self

A bold preset: weight 700, all other fields at their defaults.

Source

pub fn italic() -> Self

An italic preset: italic enabled, all other fields at their defaults.

Source

pub fn heading() -> Self

A heading preset: 24 pt, bold (weight 700).

Source

pub fn body() -> Self

A body text preset: equivalent to default().

Source

pub fn caption() -> Self

A caption preset: 11 pt, regular weight.

Source

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

Builder: override the font size in points.

Source

pub fn with_weight(self, weight: u16) -> Self

Builder: override the font weight (100–900).

Source

pub fn with_color(self, rgba: [u8; 4]) -> Self

Builder: set an explicit RGBA colour override.

Source

pub fn with_line_height(self, multiplier: f32) -> Self

Builder: set the line height multiplier.

Source

pub fn with_letter_spacing(self, spacing: f32) -> Self

Builder: set the additional letter spacing in pixels.

Source

pub fn with_underline(self, underline: bool) -> Self

Builder: enable or disable the underline decoration.

Source

pub fn with_strikethrough(self, strikethrough: bool) -> Self

Builder: enable or disable the strikethrough decoration.

Trait Implementations§

Source§

impl Clone for TextStyle

Source§

fn clone(&self) -> TextStyle

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 a regular-weight, upright style with all overrides unset.

Source§

impl PartialEq for TextStyle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 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> 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.