Trait FontResolver
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<NonZero<usize>> { ... }
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§
fn font_book(&self) -> &LazyHash<FontBook>
fn font_book(&self) -> &LazyHash<FontBook>
The font book interface for typst.
Provided Methods§
fn revision(&self) -> Option<NonZero<usize>>
fn revision(&self) -> Option<NonZero<usize>>
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
prev
ornext
isNone
, 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.
fn get_by_info(&self, info: &FontInfo) -> Option<Font>
fn get_by_info(&self, info: &FontInfo) -> Option<Font>
Gets a font by its info.
fn 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
.