Skip to main content

Font

Struct Font 

Source
pub struct Font<'a> { /* private fields */ }
Expand description

字体高阶视图(pptx.text.text.Font)。

§与 python-pptx 的对应

§设计要点

  • 借用 + 透明代理:构造时传入 &mut RunProperties
  • 零分配:颜色走 ColorFormat 借用;
  • 可空值语义name / size / lang 等字段用 Option<T>None 表示“走主题继承“——与 python-pptx None 一致。

Implementations§

Source§

impl<'a> Font<'a>

Source

pub fn new(rpr: &'a mut RunProperties) -> Font<'a>

构造。

Source

pub fn rpr(&self) -> &RunProperties

底层 rpr 不可变引用。

Source

pub fn rpr_mut(&mut self) -> &mut RunProperties

底层 rpr 可变引用。

Source

pub fn color(&mut self) -> ColorFormat<'_>

颜色 ColorFormat 代理。

Source

pub fn size(&self) -> Option<Pt>

字号(Pt)。

Source

pub fn set_size(&mut self, v: Pt)

设置字号。

Source

pub fn clear_size(&mut self)

清空字号(走主题继承)。

Source

pub fn bold(&self) -> bool

加粗。

Source

pub fn set_bold(&mut self, v: bool)

设置加粗。

Source

pub fn italic(&self) -> bool

斜体。

Source

pub fn set_italic(&mut self, v: bool)

设置斜体。

Source

pub fn strike(&self) -> bool

删除线。

Source

pub fn set_strike(&mut self, v: bool)

设置删除线。

Source

pub fn double_strike(&self) -> bool

双删除线。

对标 python-pptx font._rPr.attrib['strike'] == 'dblStrike'。 当为 true 时,写出 strike="dblStrike";普通删除线请用 Self::set_strike

Source

pub fn set_double_strike(&mut self, v: bool)

设置双删除线。

Source

pub fn highlight(&self) -> Option<&Color>

高亮色。

对标 python-pptx Font.highlight_color(v0.6.21+)。 返回 None 表示未设置高亮。

Source

pub fn set_highlight(&mut self, color: Option<Color>)

设置高亮色。

传入 None 清除高亮;传入 Color::None 也清除高亮。

Source

pub fn underline(&self) -> Option<Underline>

下划线。

Source

pub fn set_underline(&mut self, v: Option<Underline>)

设置下划线(None 表示清除)。

Source

pub fn name(&self) -> Option<&str>

字体名(拉丁)。

Source

pub fn set_name(&mut self, n: impl Into<String>)

设置字体名。

Source

pub fn clear_name(&mut self)

清空字体名(走主题继承)。

Source

pub fn eastasia_name(&self) -> Option<&str>

东亚字体。

Source

pub fn set_eastasia_name(&mut self, n: impl Into<String>)

设置东亚字体。

Source

pub fn clear_eastasia_name(&mut self)

清空东亚字体(走主题继承)。

对应 OOXML 中删除 <a:ea> 元素,PowerPoint 将使用主题的 minorFont.ea / majorFont.ea 作为回退。

Source

pub fn complex_script_name(&self) -> Option<&str>

复杂脚本字体。

Source

pub fn set_complex_script_name(&mut self, n: impl Into<String>)

设置复杂脚本字体。

Source

pub fn clear_complex_script_name(&mut self)

清空复杂脚本字体(走主题继承)。

对应 OOXML 中删除 <a:cs> 元素,PowerPoint 将使用主题的 minorFont.cs / majorFont.cs 作为回退。

Source

pub fn baseline(&self) -> Option<i32>

baseline 偏移(百分比,正=上标,负=下标)。

Source

pub fn set_baseline(&mut self, v: i32)

设置 baseline。

Source

pub fn spacing(&self) -> Option<i32>

字符间距(百分之一磅)。

Source

pub fn set_spacing(&mut self, v: i32)

设置字符间距。

取点击超链接(<a:hlinkClick>)。

设置点击超链接(直接传入 Hyperlink)。

清除点击超链接。

取悬停超链接(<a:hlinkHover>)。

设置悬停超链接。

清除悬停超链接。

便捷方法:设置一个指向 URL 的点击超链接。

§参数
  • rid:关系 ID(指向 .rels 中的目标 URL);
  • tooltip:可选的鼠标悬停提示。
§示例
run.font().set_hyperlink("rId1", Some("点击访问"));
Source

pub fn set_slide_jump(&mut self)

便捷方法:设置一个跳转幻灯片的动作超链接。

对应 OOXML action="ppaction://hlinksldjump"

Trait Implementations§

Source§

impl<'a> Debug for Font<'a>

Source§

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

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

impl<'a> From<&'a mut RunProperties> for Font<'a>

Source§

fn from(r: &'a mut RunProperties) -> Font<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Font<'a>

§

impl<'a> Freeze for Font<'a>

§

impl<'a> RefUnwindSafe for Font<'a>

§

impl<'a> Send for Font<'a>

§

impl<'a> Sync for Font<'a>

§

impl<'a> Unpin for Font<'a>

§

impl<'a> UnsafeUnpin for Font<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V