Skip to main content

StyleBuilder

Struct StyleBuilder 

Source
pub struct StyleBuilder { /* private fields */ }
Expand description

文字样式构建器(给 ParaBuilder::styled)。

Implementations§

Source§

impl StyleBuilder

Source

pub fn bold(&mut self) -> &mut Self

加粗(字重 700)。

Source

pub fn light(&mut self) -> &mut Self

细体(字重 300)。

Source

pub fn weight(&mut self, w: u16) -> &mut Self

任意字重(CSS 习惯值 1–1000,常用 100–900;越界忽略)。

Source

pub fn italic(&mut self) -> &mut Self

斜体。

Source

pub fn underline(&mut self) -> &mut Self

下划线。

Source

pub fn strike(&mut self) -> &mut Self

删除线。

Source

pub fn color(&mut self, hex: &str) -> &mut Self

文字色(十六进制;非法忽略)。

Source

pub fn bg(&mut self, hex: &str) -> &mut Self

高亮底色(十六进制;非法忽略)。

Source

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

字号倍率(相对基准)。非有限或 ≤ 0 忽略(保持默认),与标记前端一致—— 避免 0 字号把 cosmic-text 整形拖进死循环。

Source

pub fn font(&mut self, role: FontRole) -> &mut Self

字族角色。

Source

pub fn shadow(&mut self) -> &mut Self

文字阴影(默认形态:下坠 2 逻辑像素、软化 6、黑 25%)。

Source

pub fn shadow_with( &mut self, dx: f32, dy: f32, blur: f32, hex: &str, ) -> &mut Self

文字阴影(自定形态:偏移/软化为逻辑像素,色为十六进制,非法色忽略整条)。

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