pub trait FontProvider: Send + Sync {
// Provided methods
fn fonts_for_family(&self, family: &FontFamily) -> Vec<FontInsert> { ... }
fn font_for(&self, request: &FallbackRequest<'_>) -> Option<FontInsert> { ... }
}Expand description
A source of fonts.
Fonts come from two kinds of providers, and egui treats them the same once they are installed: shaped, hinted, and kerned like any other font.
- Configured fonts are known up front, and form the head of every family’s fallback chain.
FontDefinitionsis itself such a provider, and is always the first one asked. - Discovered fonts are found on demand for a character no installed font has, e.g. among the system fonts. They are appended to the family’s fallback chain.
A provider can do either or both. Providers are asked in order, and the first answer wins.
Install one with egui::Context::add_font_provider or Fonts::with_font_providers.
eframe installs a system font provider on native (behind its system_fonts feature).
Any Fn(&FallbackRequest<'_>) -> Option<FontInsert> is a discovering FontProvider.
Provided Methods§
Sourcefn fonts_for_family(&self, family: &FontFamily) -> Vec<FontInsert>
fn fonts_for_family(&self, family: &FontFamily) -> Vec<FontInsert>
The fonts to install for family up front, in priority order.
Called once per family (again after the providers change).
Sourcefn font_for(&self, request: &FallbackRequest<'_>) -> Option<FontInsert>
fn font_for(&self, request: &FallbackRequest<'_>) -> Option<FontInsert>
Find a font with a glyph for the first character of request.cluster,
after every installed font of the family missed.
Called at most once per (family, character), also when returning None.
The font is appended to the fallback chain of request.family
and of the families in FontInsert::families.
The FontPriority is ignored: discovered fonts always come after the configured ones.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl FontProvider for FontDefinitions
The configured fonts are the head of every family’s fallback chain: for each family they are handed out in the order they are listed, so the same text looks the same on every machine.
FontDefinitions never discovers anything on demand,
and is always the first FontProvider asked.