Skip to main content

CT_Font

Struct CT_Font 

Source
pub struct CT_Font {
    pub id: u32,
    pub font_name: String,
    pub family_name: Option<String>,
    pub charset: Option<String>,
    pub italic: bool,
    pub bold: bool,
    pub serif: bool,
    pub fixed_width: bool,
    pub font_file: Option<String>,
}
Expand description

对应 Java: org.ofdrw.core.text.font.CT_Font

字体描述,定义文档中使用的字体属性。 对应 GB/T 33190-2016 第 11.1 节图 58 表 44。

Fields§

§id: u32

字体 ID。

§font_name: String

字体名称(如 “SimSun”)。

§family_name: Option<String>

字体族名称(可选)。

§charset: Option<String>

字符集(可选,如 “GB2312”、“Unicode”)。

§italic: bool

是否斜体。

§bold: bool

是否粗体。

§serif: bool

是否衬线字体。

§fixed_width: bool

是否等宽字体。

§font_file: Option<String>

字体文件路径(可选)。

Implementations§

Source§

impl CT_Font

Source

pub fn new(id: u32, font_name: impl Into<String>) -> Self

创建新的字体描述。

Source

pub fn font_name(self, name: impl Into<String>) -> Self

设置字体名称。

Source

pub fn family_name(self, name: impl Into<String>) -> Self

设置字体族名称。

Source

pub fn charset(self, charset: impl Into<String>) -> Self

设置字符集。

Source

pub fn italic(self, italic: bool) -> Self

设置斜体。

Source

pub fn bold(self, bold: bool) -> Self

设置粗体。

Source

pub fn serif(self, serif: bool) -> Self

设置衬线字体。

Source

pub fn fixed_width(self, fixed: bool) -> Self

设置等宽字体。

Source

pub fn font_file(self, path: impl Into<String>) -> Self

设置字体文件路径。

Source

pub fn get_id(&self) -> u32

获取字体 ID。

Source

pub fn get_font_name(&self) -> &str

获取字体名称。

Source

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

获取字体族名称。

Source

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

获取字符集。

Source

pub fn is_italic(&self) -> bool

是否斜体。

Source

pub fn is_bold(&self) -> bool

是否粗体。

Source

pub fn is_serif(&self) -> bool

是否衬线字体。

Source

pub fn is_fixed_width(&self) -> bool

是否等宽字体。

Source

pub fn to_xml_string(&self) -> String

序列化为 OFD XML 字符串。

Trait Implementations§

Source§

impl Clone for CT_Font

Source§

fn clone(&self) -> CT_Font

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 CT_Font

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.