Skip to main content

SystemFontType

Enum SystemFontType 

Source
#[repr(C)]
pub enum SystemFontType { Ui = 0, UiBold = 1, Monospace = 2, MonospaceBold = 3, MonospaceItalic = 4, Title = 5, TitleBold = 6, Menu = 7, Small = 8, Serif = 9, SerifBold = 10, }
Expand description

System font types that can be resolved at runtime based on OS settings.

This enum allows specifying semantic font roles that get resolved to actual font families based on the current platform and user preferences. For example, Monospace resolves to:

  • macOS: SF Mono or Menlo
  • Windows: Cascadia Mono or Consolas
  • Linux: Ubuntu Mono or DejaVu Sans Mono

Font variants (bold, italic) can be combined with the base type.

Variants§

§

Ui = 0

UI font for buttons, labels, menus (SF Pro, Segoe UI, Cantarell)

§

UiBold = 1

Bold variant of UI font

§

Monospace = 2

Monospace font for code (SF Mono, Consolas, Ubuntu Mono)

§

MonospaceBold = 3

Bold variant of monospace font

§

MonospaceItalic = 4

Italic variant of monospace font

§

Title = 5

Font for window titles

§

TitleBold = 6

Bold variant of title font

§

Menu = 7

Font for menu items

§

Small = 8

Small/caption font

§

Serif = 9

Serif font for reading content (New York on macOS, Georgia on Windows)

§

SerifBold = 10

Bold variant of serif font

Implementations§

Source§

impl SystemFontType

Source

pub fn from_css_str(s: &str) -> Option<Self>

Parse a SystemFontType from a CSS string.

Supported formats:

  • system:ui, system:ui:bold
  • system:monospace, system:monospace:bold, system:monospace:italic
  • system:title, system:title:bold
  • system:menu
  • system:small
  • system:serif, system:serif:bold
Source

pub fn as_css_str(&self) -> &'static str

Get the CSS syntax for this system font type.

Source

pub fn is_bold(&self) -> bool

Returns true if this system font type implies bold weight. Used when resolving system fonts to pass the correct weight to fontconfig.

Source

pub fn is_italic(&self) -> bool

Returns true if this system font type implies italic style.

Source§

impl SystemFontType

Source

pub fn get_fallback_chain(&self, platform: &Platform) -> Vec<&'static str>

Returns the font fallback chain for this font type on the given platform.

The returned list contains font family names in order of preference. The first available font should be used.

Trait Implementations§

Source§

impl Clone for SystemFontType

Source§

fn clone(&self) -> SystemFontType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SystemFontType

Source§

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

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

impl Default for SystemFontType

Source§

fn default() -> Self

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

impl Hash for SystemFontType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SystemFontType

Source§

fn cmp(&self, other: &SystemFontType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SystemFontType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SystemFontType

Source§

fn partial_cmp(&self, other: &SystemFontType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for SystemFontType

Source§

impl Eq for SystemFontType

Source§

impl StructuralPartialEq for SystemFontType

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> GetHash for T
where T: Hash,

Source§

fn get_hash(&self) -> u64

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.