Skip to main content

FontConfig

Struct FontConfig 

Source
pub struct FontConfig {
    pub family: String,
    pub size: f32,
}
Expand description

字体配置:族名 + 逻辑像素字号。

注意:字号是全局的——文本引擎只用一个字号, 不支持同一文档内不同字号(富文本)。若将来需要富文本, 再给 TextStyle 加 font_size 字段并让 measure_text 读它。

Fields§

§family: String

字体族名(DirectWrite family name),例如 "NSimSun" / "JetBrains Mono"。

§size: f32

字号(逻辑像素)。

Implementations§

Source§

impl FontConfig

Source

pub fn modern() -> Self

现代比例字体(Windows 10/11 自带):Microsoft YaHei UI。

⚠️ 先读这段再用:Y901 的文本模型是等宽 cell (cell_metrics_for 固定按 0.5em × 1em 出 cell,绘制时按 cell_span × cell.w 步进), 所以比例字体只会被“按固定步进“放置 —— 字母间距会不均匀、窄字母偏松、 中文与西文混排时位置会偏。它适合做视觉试验,不适合当默认。

默认仍是 NSimSun(等宽、中英文齐全),原因就在上面这条。

Trait Implementations§

Source§

impl Clone for FontConfig

Source§

fn clone(&self) -> Self

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 FontConfig

Source§

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

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

impl Default for FontConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for FontConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FontConfig

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.