Struct cosmic_text::FontSystem

source ·
pub struct FontSystem { /* private fields */ }
Expand description

Access to the system fonts.

Implementations§

source§

impl FontSystem

source

pub fn new() -> Self

Create a new FontSystem, that allows access to any installed system fonts

§Timing

This function takes some time to run. On the release build, it can take up to a second, while debug builds can take up to ten times longer. For this reason, it should only be called once, and the resulting FontSystem should be shared.

source

pub fn new_with_fonts(fonts: impl IntoIterator<Item = Source>) -> Self

Create a new FontSystem with a pre-specified set of fonts.

source

pub fn new_with_locale_and_db(locale: String, db: Database) -> Self

Create a new FontSystem with a pre-specified locale and font database.

source

pub fn locale(&self) -> &str

Get the locale.

source

pub fn db(&self) -> &Database

Get the database.

source

pub fn db_mut(&mut self) -> &mut Database

Get a mutable reference to the database.

source

pub fn into_locale_and_db(self) -> (String, Database)

Consume this FontSystem and return the locale and database.

source

pub fn get_font(&mut self, id: ID) -> Option<Arc<Font>>

Get a font by its ID.

source

pub fn is_monospace(&self, id: ID) -> bool

source

pub fn get_monospace_ids_for_scripts( &self, scripts: impl Iterator<Item = [u8; 4]> ) -> Vec<ID>

source

pub fn get_font_supported_codepoints_in_word( &mut self, id: ID, word: &str ) -> Option<usize>

source

pub fn get_font_matches(&mut self, attrs: Attrs<'_>) -> Arc<Vec<FontMatchKey>>

Trait Implementations§

source§

impl Debug for FontSystem

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.