Skip to main content

PageChrome

Struct PageChrome 

Source
pub struct PageChrome {
    pub inlines: Vec<Inline>,
    pub trailing: Option<Vec<Inline>>,
    pub align: Align,
    pub color: Option<Color>,
    pub size: f32,
    pub rule: bool,
    pub band: Option<Color>,
}
Expand description

页眉 / 页脚条:一行小字(可富文本)+ 可选的与内容之间的细分割线。参与布局高度 (measure_document 自然包含),不归文档内容管——同一品牌 标识配在 RenderOptions 上,所有出图统一带。

Fields§

§inlines: Vec<Inline>

行内内容(纯文字经 new,富文本经 rich)。

§trailing: Option<Vec<Inline>>

行尾内容(可选):与 inlines 同一行,右对齐——「左 logo 右署名」的分栏形态。 设了它,align 只管 inlines(通常配左对齐)。

§align: Align

水平对齐(with_header 默认左、with_footer 默认居中)。

§color: Option<Color>

缺省文字色:未显式上色的 span 用它;None = 主题次要色(muted)。

§size: f32

相对基准字号的倍率(默认 0.72)。

§rule: bool

与内容之间画一条细线(默认开;设了 band 自动不画)。

§band: Option<Color>

满幅色带(可选,仅页脚生效):整条画布宽的底色带贴住画布底,文字坐在带内—— 分享卡式的「底栏」。设色深时记得给 span 配亮色文字。

Implementations§

Source§

impl PageChrome

Source

pub fn new(text: impl Into<String>) -> Self

默认形态:次要色小字、带细线、左对齐。

Source

pub fn rich<R>(f: impl FnOnce(&mut ParaBuilder) -> R) -> Self

富文本形态:闭包拼行内(粗细 / 色 / 字号倍率皆可,如品牌名加重、连接词浅色)。 p.styled("abot", |s| { s.weight(600); }) 这类未显式上色的 span 仍按缺省色染。

Source

pub fn trailing<R>(self, f: impl FnOnce(&mut ParaBuilder) -> R) -> Self

设行尾内容(右对齐,与主内容同一行):「左 logo 右署名」分栏。

Source

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

设满幅色带(十六进制;非法忽略)。仅页脚生效,自动不再画细线。

Source

pub fn align(self, a: Align) -> Self

设对齐。

Source

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

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

Source

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

设字号倍率(非法忽略)。

Source

pub fn no_rule(self) -> Self

不画细线。

Trait Implementations§

Source§

impl Clone for PageChrome

Source§

fn clone(&self) -> PageChrome

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 PageChrome

Source§

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

Formats the value using the given formatter. Read more

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.