pub struct Font<'a> { /* private fields */ }Expand description
字体高阶视图(pptx.text.text.Font)。
§与 python-pptx 的对应
pptx.text.text.Font←→Font;font.bold = True/font.size = Pt(24)/font.color.rgb = RGBColor(...)←→Font::set_bold/Font::set_size/Font::color.set_rgb()。
§设计要点
- 借用 + 透明代理:构造时传入
&mut RunProperties; - 零分配:颜色走
ColorFormat借用; - 可空值语义:
name/size/lang等字段用Option<T>,None表示“走主题继承“——与 python-pptxNone一致。
Implementations§
Source§impl<'a> Font<'a>
impl<'a> Font<'a>
Sourcepub fn new(rpr: &'a mut RunProperties) -> Font<'a>
pub fn new(rpr: &'a mut RunProperties) -> Font<'a>
构造。
Sourcepub fn rpr(&self) -> &RunProperties
pub fn rpr(&self) -> &RunProperties
底层 rpr 不可变引用。
Sourcepub fn rpr_mut(&mut self) -> &mut RunProperties
pub fn rpr_mut(&mut self) -> &mut RunProperties
底层 rpr 可变引用。
Sourcepub fn color(&mut self) -> ColorFormat<'_>
pub fn color(&mut self) -> ColorFormat<'_>
颜色 ColorFormat 代理。
Sourcepub fn clear_size(&mut self)
pub fn clear_size(&mut self)
清空字号(走主题继承)。
Sourcepub fn set_italic(&mut self, v: bool)
pub fn set_italic(&mut self, v: bool)
设置斜体。
Sourcepub fn set_strike(&mut self, v: bool)
pub fn set_strike(&mut self, v: bool)
设置删除线。
Sourcepub fn double_strike(&self) -> bool
pub fn double_strike(&self) -> bool
双删除线。
对标 python-pptx font._rPr.attrib['strike'] == 'dblStrike'。
当为 true 时,写出 strike="dblStrike";普通删除线请用 Self::set_strike。
Sourcepub fn set_double_strike(&mut self, v: bool)
pub fn set_double_strike(&mut self, v: bool)
设置双删除线。
Sourcepub fn highlight(&self) -> Option<&Color>
pub fn highlight(&self) -> Option<&Color>
高亮色。
对标 python-pptx Font.highlight_color(v0.6.21+)。
返回 None 表示未设置高亮。
Sourcepub fn set_highlight(&mut self, color: Option<Color>)
pub fn set_highlight(&mut self, color: Option<Color>)
设置高亮色。
传入 None 清除高亮;传入 Color::None 也清除高亮。
Sourcepub fn set_underline(&mut self, v: Option<Underline>)
pub fn set_underline(&mut self, v: Option<Underline>)
设置下划线(None 表示清除)。
Sourcepub fn clear_name(&mut self)
pub fn clear_name(&mut self)
清空字体名(走主题继承)。
Sourcepub fn eastasia_name(&self) -> Option<&str>
pub fn eastasia_name(&self) -> Option<&str>
东亚字体。
Sourcepub fn set_eastasia_name(&mut self, n: impl Into<String>)
pub fn set_eastasia_name(&mut self, n: impl Into<String>)
设置东亚字体。
Sourcepub fn clear_eastasia_name(&mut self)
pub fn clear_eastasia_name(&mut self)
清空东亚字体(走主题继承)。
对应 OOXML 中删除 <a:ea> 元素,PowerPoint 将使用主题的
minorFont.ea / majorFont.ea 作为回退。
Sourcepub fn complex_script_name(&self) -> Option<&str>
pub fn complex_script_name(&self) -> Option<&str>
复杂脚本字体。
Sourcepub fn set_complex_script_name(&mut self, n: impl Into<String>)
pub fn set_complex_script_name(&mut self, n: impl Into<String>)
设置复杂脚本字体。
Sourcepub fn clear_complex_script_name(&mut self)
pub fn clear_complex_script_name(&mut self)
清空复杂脚本字体(走主题继承)。
对应 OOXML 中删除 <a:cs> 元素,PowerPoint 将使用主题的
minorFont.cs / majorFont.cs 作为回退。
Sourcepub fn set_baseline(&mut self, v: i32)
pub fn set_baseline(&mut self, v: i32)
设置 baseline。
Sourcepub fn set_spacing(&mut self, v: i32)
pub fn set_spacing(&mut self, v: i32)
设置字符间距。
Sourcepub fn hlink_click(&self) -> Option<&Hyperlink>
pub fn hlink_click(&self) -> Option<&Hyperlink>
取点击超链接(<a:hlinkClick>)。
Sourcepub fn set_hlink_click(&mut self, hl: Hyperlink)
pub fn set_hlink_click(&mut self, hl: Hyperlink)
设置点击超链接(直接传入 Hyperlink)。
Sourcepub fn clear_hlink_click(&mut self)
pub fn clear_hlink_click(&mut self)
清除点击超链接。
Sourcepub fn hlink_hover(&self) -> Option<&Hyperlink>
pub fn hlink_hover(&self) -> Option<&Hyperlink>
取悬停超链接(<a:hlinkHover>)。
Sourcepub fn set_hlink_hover(&mut self, hl: Hyperlink)
pub fn set_hlink_hover(&mut self, hl: Hyperlink)
设置悬停超链接。
Sourcepub fn clear_hlink_hover(&mut self)
pub fn clear_hlink_hover(&mut self)
清除悬停超链接。
Sourcepub fn set_slide_jump(&mut self)
pub fn set_slide_jump(&mut self)
便捷方法:设置一个跳转幻灯片的动作超链接。
对应 OOXML action="ppaction://hlinksldjump"。
Trait Implementations§
Source§impl<'a> From<&'a mut RunProperties> for Font<'a>
impl<'a> From<&'a mut RunProperties> for Font<'a>
Source§fn from(r: &'a mut RunProperties) -> Font<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more