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

字族角色。

链接样式:无显式色时按主题强调色渲(与标记文本 [文字](URL) 同款;引擎不存 URL)。

Source

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

圈注:以这段文字为中心画一圈椭圆描边(缺省按文字宽窄自适应、颜色跟随墨色; 不占布局尺寸,圈溢出到行距)。尺寸经 ring_radius / ring_radii 给定后与文字宽窄无关。

Source

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

圈注描边色(十六进制;非法忽略,跟随墨色)。

Source

pub fn ring_radius(&mut self, r: f32) -> &mut Self

圈注定径:正圆,半径 r(逻辑像素)——多字与单字圈出同样大的圈。

Source

pub fn ring_radii(&mut self, rx: f32, ry: f32) -> &mut Self

圈注定径:椭圆,横/纵半径(逻辑像素)。非有限或 ≤ 0 的分量忽略(保持自适应)。

Source

pub fn ring_stroke(&mut self, w: f32) -> &mut Self

圈注线宽(逻辑像素;非有限或 ≤ 0 忽略,保持 0.07 倍字号缺省)。

Source

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

逐字圈:整段一字一圈(空白跳过),未定径时按字取正圆。缺省是整段一个圈 (范围圈,自适应为扁椭圆)。

Source

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

着重点:这段文字正下方一枚实心小点(颜色跟随墨色;画进行距,不占高度)。

Source

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

着重点颜色(十六进制;非法忽略,跟随墨色)。

Source

pub fn dot_radius(&mut self, r: f32) -> &mut Self

着重点半径(逻辑像素;非有限或 ≤ 0 忽略,保持 0.09 倍字号缺省)。

Source

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

逐字点:一字一点(中文着重号的正字法;空白跳过)。缺省是整段中线下一点。

Source

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

边注挂右:这段挂到本行内容的右外侧,参与绘制不参与布局——居中 / 对齐按其余 内容算,边注不挤不偏(「当前」「✓」这类行尾标记用)。

Source

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

边注挂左:同 aside_right,停靠行首左外侧。

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.