pub enum Font {
Builtin {
encoding: Encoding,
},
Cff {
encoding: Encoding,
data: Vec<u8>,
cid_to_gid: Vec<(u16, u16)>,
},
TrueType {
encoding: Encoding,
data: Vec<u8>,
},
}Expand description
A resolved font ready to place glyphs.
Variants§
Builtin
The built-in fallback: a 5×7 bitmap alphabet, used when the document carries no usable font program (all of the base-14 cases).
Cff
An embedded CFF program, wrapped so the outlines come out of the same code path as TrueType. CID-keyed fonts select glyphs through their charset, not by using the CID as a glyph id.
Fields
TrueType
An embedded TrueType program.
Implementations§
Source§impl Font
impl Font
Sourcepub fn cff(encoding: Encoding, data: Vec<u8>) -> Option<Self>
pub fn cff(encoding: Encoding, data: Vec<u8>) -> Option<Self>
An embedded CFF program, bare or already wrapped in OpenType.
/CIDFontType0C and /Type1C programs are a CFF table with no container;
they are wrapped here so the same outline code reads them.
Sourcepub fn true_type(encoding: Encoding, data: Vec<u8>) -> Option<Self>
pub fn true_type(encoding: Encoding, data: Vec<u8>) -> Option<Self>
An embedded TrueType program, rejected when it cannot be parsed.
Sourcepub fn glyph(&self, code: u8) -> Option<Glyph>
pub fn glyph(&self, code: u8) -> Option<Glyph>
The outline and advance for a byte code, or None when there is no
glyph for it.
Sourcepub fn advance(&self, code: u8) -> f64
pub fn advance(&self, code: u8) -> f64
The advance of a code in em units, falling back to the built-in metric.
Sourcepub fn glyph_by_id(&self, id: u16) -> Option<Glyph>
pub fn glyph_by_id(&self, id: u16) -> Option<Glyph>
The outline for a glyph id, which is how composite (Type 0) fonts select
glyphs: a CID maps to an id through /CIDToGIDMap, not through a cmap.
The built-in bitmap alphabet has no glyph ids, so it has no answer here.