pub struct FontSystem { /* private fields */ }Expand description
Access to the system fonts.
Implementations§
Source§impl FontSystem
impl FontSystem
Sourcepub fn new() -> Self
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.
Sourcepub fn new_with_fonts(fonts: impl IntoIterator<Item = Source>) -> Self
pub fn new_with_fonts(fonts: impl IntoIterator<Item = Source>) -> Self
Create a new FontSystem with a pre-specified set of fonts.
Sourcepub fn new_cached() -> Self
pub fn new_cached() -> Self
Create a new FontSystem backed by a persistent on-disk system-font index cache
at the platform’s conventional cache location
(e.g. $XDG_CACHE_HOME/cosmic-text/fonts.cache).
Falls back to a normal, uncached scan if no cache directory can be determined.
Sourcepub fn default_cache_path() -> Option<PathBuf>
pub fn default_cache_path() -> Option<PathBuf>
Returns the default system-font cache file path used by FontSystem::new_cached
and FontSystem::new_with_fonts_and_cache
(<cache-dir>/cosmic-text/fonts.cache, following the platform’s conventional cache
directory).
Returns None if no cache directory can be determined from the environment.
Sourcepub fn new_with_fonts_and_cache(fonts: impl IntoIterator<Item = Source>) -> Self
pub fn new_with_fonts_and_cache(fonts: impl IntoIterator<Item = Source>) -> Self
Like FontSystem::new_with_fonts, but reads from and writes to a persistent
system-font index cache at the default platform cache location (see
FontSystem::new_cached).
The cache path is resolved automatically; if no cache directory can be determined
this falls back to a normal, uncached scan.
The user-provided fonts are always loaded fresh and
are never persisted to the cache
To cache at an explicit location instead, use
FontSystem::new_with_fonts_and_cache_path.
Sourcepub fn new_with_fonts_and_cache_path(
fonts: impl IntoIterator<Item = Source>,
cache_path: PathBuf,
) -> Self
pub fn new_with_fonts_and_cache_path( fonts: impl IntoIterator<Item = Source>, cache_path: PathBuf, ) -> Self
Like FontSystem::new_with_fonts_and_cache, but uses the persistent system-font
index cache at the explicitly provided cache_path rather than the default
location.
Sourcepub fn new_with_locale_and_db_and_fallback(
locale: String,
db: Database,
impl_fallback: impl Fallback + 'static,
) -> Self
pub fn new_with_locale_and_db_and_fallback( locale: String, db: Database, impl_fallback: impl Fallback + 'static, ) -> Self
Create a new FontSystem with a pre-specified locale, font database and font fallback list.
Sourcepub fn new_with_locale_and_db(locale: String, db: Database) -> Self
pub fn new_with_locale_and_db(locale: String, db: Database) -> Self
Create a new FontSystem with a pre-specified locale and font database.
Sourcepub fn into_locale_and_db(self) -> (String, Database)
pub fn into_locale_and_db(self) -> (String, Database)
Consume this FontSystem and return the locale and database.
Sourcepub fn get_font(&mut self, id: ID, weight: Weight) -> Option<Arc<Font>>
pub fn get_font(&mut self, id: ID, weight: Weight) -> Option<Arc<Font>>
Get a font by its ID and weight.