pub struct Font { /* private fields */ }Implementations§
Source§impl Font
impl Font
Sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
The raw file bytes — possibly a whole .ttc collection; pair every
face view with Self::face_index.
Sourcepub fn face_index(&self) -> u32
pub fn face_index(&self) -> u32
Which face of Self::data this font is.
Sourcepub fn variation_coordinates(&self) -> &[([u8; 4], f32)]
pub fn variation_coordinates(&self) -> &[([u8; 4], f32)]
User-space variation coordinates ((axis tag, value)); empty for the default instance and for static fonts.
pub fn family(&self) -> &str
pub fn aliases(&self) -> &[String]
Sourcepub fn matches(&self, name: &str) -> bool
pub fn matches(&self, name: &str) -> bool
Does this face answer to name? (its family or any alias —
ASCII-case-insensitively, the CSS and platform-manager behavior)
Sourcepub fn add_alias(&mut self, name: &str)
pub fn add_alias(&mut self, name: &str)
Register one more name for this face (no-op if already answered).
pub fn attrs(&self) -> FontAttrs
Sourcepub fn descent_px(&self, size: f32) -> f32
pub fn descent_px(&self, size: f32) -> f32
Descent in px at size (positive, below the baseline).
Sourcepub fn line_height_px(&self, size: f32) -> f32
pub fn line_height_px(&self, size: f32) -> f32
Default line height in px at size.
pub fn units_per_em(&self) -> f32
Sourcepub fn ink_box_px(&self, size: f32) -> Option<(f32, f32, f32, f32)>
pub fn ink_box_px(&self, size: f32) -> Option<(f32, f32, f32, f32)>
The font-wide ink box at size, y-UP around the glyph origin:
(x_min, y_min, x_max, y_max). Any glyph’s ink fits inside — the
cheap way to bound italic overhang and mark excursions per run.
pub fn covers(&self, ch: char) -> bool
Sourcepub fn underline_px(&self, size: f32) -> (f32, f32)
pub fn underline_px(&self, size: f32) -> (f32, f32)
Underline (offset below baseline, thickness) in px at size, with
conventional fallbacks when the font omits the post-table values.
Sourcepub fn strikeout_px(&self, size: f32) -> (f32, f32)
pub fn strikeout_px(&self, size: f32) -> (f32, f32)
Strikeout (offset ABOVE baseline, thickness) in px at size.
Source§impl Font
impl Font
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Option<Font>
pub fn from_bytes(bytes: Vec<u8>) -> Option<Font>
Parse a font file into a queryable object: family and weight/style
come from the file’s own tables (Skia’s SkTypeface::MakeFromData
shape — parse once, inspect, then FontCollection::add). Every
localized family name becomes an alias (fontdb keeps them all —
documents reference 优设标题黑 as readily as YouSheBiaoTiHei).
Sourcepub fn from_data(data: FontData, face_index: u32) -> Option<Font>
pub fn from_data(data: FontData, face_index: u32) -> Option<Font>
Self::from_bytes for shared or memory-mapped bytes and for
collection files: face_index picks the face inside a .ttc (0 for
single-face files).
Sourcepub fn instances_from_data(data: FontData, face_index: u32) -> Vec<Font>
pub fn instances_from_data(data: FontData, face_index: u32) -> Vec<Font>
Every face a file offers for registration: a static font is itself;
a variable font is its NAMED INSTANCES (fvar), each a Font with
the instance’s attrs and coordinates — nearest-variant matching
then picks weights exactly like a static multi-weight family.