pub trait FontResolver {
// Required methods
fn font_book(&self) -> &LazyHash<FontBook>;
fn slot(&self, index: usize) -> Option<&FontSlot>;
fn font(&self, index: usize) -> Option<Font>;
// Provided methods
fn revision(&self) -> Option<NonZeroUsize> { ... }
fn get_by_info(&self, info: &FontInfo) -> Option<Font> { ... }
fn default_get_by_info(&self, info: &FontInfo) -> Option<Font> { ... }
}Expand description
A FontResolver can resolve a font by index.
It also provides FontBook for typst to query fonts.
Required Methods§
Provided Methods§
Sourcefn revision(&self) -> Option<NonZeroUsize>
fn revision(&self) -> Option<NonZeroUsize>
An optionally implemented revision function for users, e.g. the World.
A user of FontResolver will differentiate the prev and next
revisions to determine if the underlying state of fonts has changed.
- If either
prevornextisNone, the world’s revision is always increased. - Otherwise, the world’s revision is increased if
prev != next.
If the revision of fonts is changed, the world will invalidate all related caches and increase its revision.
Sourcefn get_by_info(&self, info: &FontInfo) -> Option<Font>
fn get_by_info(&self, info: &FontInfo) -> Option<Font>
Gets a font by its info.
Sourcefn default_get_by_info(&self, info: &FontInfo) -> Option<Font>
fn default_get_by_info(&self, info: &FontInfo) -> Option<Font>
The default implementation of FontResolver::get_by_info.