pub struct Face { /* private fields */ }Expand description
A font face, owning its bytes.
The bytes are Arc’d and the reader is rebuilt per use rather than stored.
Opening only validates a header, so this is a handful of bounds checks —
cheap next to drawing a glyph, and it keeps the type free of the
self-reference a borrowed FontRef<'static> would need.
Implementations§
Source§impl Face
impl Face
Sourcepub fn new(bytes: Arc<[u8]>, index: u32) -> Option<Self>
pub fn new(bytes: Arc<[u8]>, index: u32) -> Option<Self>
Read a face from a font program.
Accepts anything with a table directory — TrueType, bare CFF,
OpenType/CFF, and a TrueType Collection member by index. Returns
None for a blob no backend recognises, which is the signal to fall
back to pdfrum_type1 and then to substitution.
Sourcepub fn units_per_em(&self) -> u16
pub fn units_per_em(&self) -> u16
Design units per em.
Sourcepub fn num_glyphs(&self) -> u32
pub fn num_glyphs(&self) -> u32
How many glyphs the face declares.
Sourcepub fn is_truetype(&self) -> bool
pub fn is_truetype(&self) -> bool
Whether outlines come from a glyf table.
Sourcepub fn charmaps(&self) -> Vec<CharmapId>
pub fn charmaps(&self) -> Vec<CharmapId>
The (platform, encoding) pairs the cmap table declares, in table
order — which is the order every ladder scans them in.
Sourcepub fn char_index(&self, charmap: Charmap, code: u32) -> u16
pub fn char_index(&self, charmap: Charmap, code: u32) -> u16
The glyph a code selects through charmap. Zero on any miss.
Sourcepub fn name_index(&self, name: &str) -> u16
pub fn name_index(&self, name: &str) -> u16
The glyph a name selects. Zero on a miss.
Sourcepub fn glyph_name(&self, gid: Gid) -> Option<String>
pub fn glyph_name(&self, gid: Gid) -> Option<String>
A glyph’s own name.
Sourcepub fn has_glyph_names(&self) -> bool
pub fn has_glyph_names(&self) -> bool
Whether the face carries glyph names at all.
Sourcepub fn postscript_name(&self) -> Option<String>
pub fn postscript_name(&self) -> Option<String>
The PostScript name (name ID 6), falling back to the family name.
Sourcepub fn is_fixed_pitch(&self) -> bool
pub fn is_fixed_pitch(&self) -> bool
post.isFixedPitch, or false when the table is missing.
Sourcepub fn is_italic(&self) -> bool
pub fn is_italic(&self) -> bool
Italic from OS/2 fsSelection, head.macStyle, or a non-zero post.italicAngle.
Sourcepub fn is_bold(&self) -> bool
pub fn is_bold(&self) -> bool
Bold from OS/2 fsSelection / usWeightClass >= 700, or head.macStyle.
Sourcepub fn cap_height(&self) -> Option<f32>
pub fn cap_height(&self) -> Option<f32>
OS/2 sCapHeight in font units, when the table is version 2 or later.