pub struct FontRegistry { /* private fields */ }Expand description
The registry: assigns font_ids, hands shaper access and metrics
to the pipeline, and maps generic families to bundled faces.
Ids are dense and sequential from 0 — an id is an index.
Implementations§
Source§impl FontRegistry
impl FontRegistry
Sourcepub fn add(&mut self, source: FontSource) -> Result<Vec<u16>, FontError>
pub fn add(&mut self, source: FontSource) -> Result<Vec<u16>, FontError>
Registers a font file and returns the ids of the faces it yielded, in the order the file names them.
A variable file yields one face per named instance: the cuts the family says it has. Matching is then a lookup over faces with fixed slopes and weights, which is what lets the cascade resolve a face without a registry it may write to.
Decodes metrics eagerly: a font that can’t be parsed fails here, once, rather than at first shape.
Sourcepub fn map_generic(
&mut self,
generic: GenericFamily,
family: &str,
) -> Option<u16>
pub fn map_generic( &mut self, generic: GenericFamily, family: &str, ) -> Option<u16>
Binds a generic keyword to a registered family’s first face. The keyword must not already be bound.
Sourcepub fn generic(&self, generic: GenericFamily) -> Option<u16>
pub fn generic(&self, generic: GenericFamily) -> Option<u16>
The id a generic keyword resolves to.
Sourcepub fn by_family(&self, family: &str) -> Option<u16>
pub fn by_family(&self, family: &str) -> Option<u16>
The id of the first face whose family matches (case-insensitive compare against the lowercased registry key).
Sourcepub fn select(&self, family: &str, want: FaceAttributes) -> Option<FaceMatch>
pub fn select(&self, family: &str, want: FaceAttributes) -> Option<FaceMatch>
The face of family that best answers a slope and weight.
Matching follows CSS: slope decides first — a family with an italic cut never answers an italic request with the upright — and weight is then chosen by the desired-weight rules, which look up before they look down in the text range and away from it elsewhere. The match reports what it actually found, so a caller can say when the family had nothing at the slope asked for.
Sourcepub fn font_ref(&self, id: u16) -> Option<&FontRefEntry>
pub fn font_ref(&self, id: u16) -> Option<&FontRefEntry>
Identity of a face, for the output font table.
Sourcepub fn metrics(&self, id: u16) -> Option<FontMetricsTable>
pub fn metrics(&self, id: u16) -> Option<FontMetricsTable>
Metrics of a face, in font units.
Sourcepub fn has_small_caps(&self, id: u16) -> bool
pub fn has_small_caps(&self, id: u16) -> bool
Whether a face draws small capitals of its own. A face that does not has to have them synthesized from its capitals.
Sourcepub fn has_feature(&self, id: u16, tag: [u8; 4]) -> bool
pub fn has_feature(&self, id: u16, tag: [u8; 4]) -> bool
Whether a face carries one feature. A sheet that asks for a feature the face has nothing for gets the run set without it.
Sourcepub fn bytes(&self, id: u16) -> Option<Arc<Vec<u8>>>
pub fn bytes(&self, id: u16) -> Option<Arc<Vec<u8>>>
The raw bytes of a face, for embedding at write time.
Shared: the faces a variable file yielded are one file, and a painter embeds one copy of it however many cuts it draws.
Sourcepub fn variations(&self, id: u16) -> Option<&[AxisSetting]>
pub fn variations(&self, id: u16) -> Option<&[AxisSetting]>
Where on its file’s axes a face sits, in user space. Empty for a static face and for a variable one at its default location.
Sourcepub fn advance_width(&self, id: u16, glyph: u32) -> Option<u16>
pub fn advance_width(&self, id: u16, glyph: u32) -> Option<u16>
Advance width of one glyph, in font units.
Sourcepub fn advance_widths(&self, id: u16, glyphs: &[u32]) -> Option<Vec<u16>>
pub fn advance_widths(&self, id: u16, glyphs: &[u32]) -> Option<Vec<u16>>
The advance widths of a run of glyphs, in font units.
Shaped output is glyph ids; measuring them must not re-decode the font per glyph, so this batches.
Sourcepub fn char_glyph(&self, id: u16, ch: char) -> Option<u32>
pub fn char_glyph(&self, id: u16, ch: char) -> Option<u32>
Maps one character to its nominal glyph, in font units.
Sourcepub fn shape(&self, id: u16, text: &str) -> Option<Vec<ShapedGlyph>>
pub fn shape(&self, id: u16, text: &str) -> Option<Vec<ShapedGlyph>>
Shapes a string with a registered face, in font units.
Returns per-glyph ShapedGlyph — the raw material of line
layout. Clusters index the shaped string, so callers can map
text offsets (break opportunities) back to glyphs; offsets data
stays in the shaper’s buffer.
Sourcepub fn shape_with(
&self,
id: u16,
text: &str,
features: &Features,
) -> Option<Vec<ShapedGlyph>>
pub fn shape_with( &self, id: u16, text: &str, features: &Features, ) -> Option<Vec<ShapedGlyph>>
The same, with the features a style asked for turned on.
Trait Implementations§
Source§impl Default for FontRegistry
impl Default for FontRegistry
Source§fn default() -> FontRegistry
fn default() -> FontRegistry
Auto Trait Implementations§
impl Freeze for FontRegistry
impl RefUnwindSafe for FontRegistry
impl Send for FontRegistry
impl Sync for FontRegistry
impl Unpin for FontRegistry
impl UnsafeUnpin for FontRegistry
impl UnwindSafe for FontRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.