pub struct FontData {
pub id: FontId,
pub canonical_name: String,
/* private fields */
}Expand description
Loaded font identity plus its face source.
Fields§
§id: FontIdStable font identity.
canonical_name: StringCanonical font family or face name.
Implementations§
Source§impl FontData
impl FontData
Sourcepub fn new(
id: FontId,
canonical_name: impl Into<String>,
bytes: impl Into<Arc<[u8]>>,
) -> Self
pub fn new( id: FontId, canonical_name: impl Into<String>, bytes: impl Into<Arc<[u8]>>, ) -> Self
Create font data from an id, canonical name, and raw bytes; the library parses lazily, once.
Create font data from a face the application already parsed; the library never parses it.
Sourcepub fn bytes(&self) -> Option<&Arc<[u8]>>
pub fn bytes(&self) -> Option<&Arc<[u8]>>
Returns the raw bytes when the library owns them; None for application shared faces.
Sourcepub fn with_ttf_face<R>(
&self,
f: impl FnOnce(&Face<'_>) -> R,
) -> Result<R, FontError>
pub fn with_ttf_face<R>( &self, f: impl FnOnce(&Face<'_>) -> R, ) -> Result<R, FontError>
Runs f with the ttf face; parsed at most once, shared across clones.
Sourcepub fn with_rustybuzz_face<R>(
&self,
f: impl FnOnce(&Face<'_>) -> R,
) -> Result<R, FontError>
pub fn with_rustybuzz_face<R>( &self, f: impl FnOnce(&Face<'_>) -> R, ) -> Result<R, FontError>
Runs f with the rustybuzz face; parsed at most once, shared across clones and with shaping.
Sourcepub fn metrics(&self, size: Length) -> Result<FontMetrics, FontError>
pub fn metrics(&self, size: Length) -> Result<FontMetrics, FontError>
Parse overall font metrics at the requested size.
Sourcepub fn glyph_metrics(
&self,
glyph: GlyphId,
size: Length,
) -> Result<FontGlyphMetrics, FontError>
pub fn glyph_metrics( &self, glyph: GlyphId, size: Length, ) -> Result<FontGlyphMetrics, FontError>
Return metrics for a glyph at the requested size.
Sourcepub fn glyph_outlines(
&self,
glyphs: &[GlyphId],
) -> Result<Vec<Option<GlyphOutline>>, FontError>
pub fn glyph_outlines( &self, glyphs: &[GlyphId], ) -> Result<Vec<Option<GlyphOutline>>, FontError>
Return outlines in font design units with y pointing up, one entry per input glyph.
Sourcepub fn glyph_index(&self, codepoint: char) -> Result<Option<GlyphId>, FontError>
pub fn glyph_index(&self, codepoint: char) -> Result<Option<GlyphId>, FontError>
Look up a glyph id by Unicode codepoint.
Sourcepub fn glyph_index_by_name(
&self,
name: &str,
) -> Result<Option<GlyphId>, FontError>
pub fn glyph_index_by_name( &self, name: &str, ) -> Result<Option<GlyphId>, FontError>
Look up a glyph id by glyph name.
Sourcepub fn has_opentype_math(&self) -> Result<bool, FontError>
pub fn has_opentype_math(&self) -> Result<bool, FontError>
Report whether the font has an OpenType math table.
Sourcepub fn ot_glyph_count(&self) -> Result<u32, FontError>
pub fn ot_glyph_count(&self) -> Result<u32, FontError>
Number of glyphs in the font (\XeTeXcountglyphs).
Sourcepub fn ot_script_count(&self) -> Result<u32, FontError>
pub fn ot_script_count(&self) -> Result<u32, FontError>
Number of OpenType layout scripts from the larger layout script list.
Sourcepub fn ot_script_tag(&self, index: u32) -> Result<u32, FontError>
pub fn ot_script_tag(&self, index: u32) -> Result<u32, FontError>
OpenType script tag at index, packed big endian to match XeTeX hb_tag_t encoding.
Sourcepub fn ot_language_count(&self, script_tag: u32) -> Result<u32, FontError>
pub fn ot_language_count(&self, script_tag: u32) -> Result<u32, FontError>
Number of languages under script_tag, summed across OpenType layout tables.
Sourcepub fn ot_language_tag(
&self,
script_tag: u32,
index: u32,
) -> Result<u32, FontError>
pub fn ot_language_tag( &self, script_tag: u32, index: u32, ) -> Result<u32, FontError>
Language tag at index under script_tag (\XeTeXOTlanguagetag).
Sourcepub fn ot_feature_count(
&self,
script_tag: u32,
language_tag: u32,
) -> Result<u32, FontError>
pub fn ot_feature_count( &self, script_tag: u32, language_tag: u32, ) -> Result<u32, FontError>
Number of features under script_tag and language_tag, summed across OpenType layout tables.
Sourcepub fn ot_feature_tag(
&self,
script_tag: u32,
language_tag: u32,
index: u32,
) -> Result<u32, FontError>
pub fn ot_feature_tag( &self, script_tag: u32, language_tag: u32, index: u32, ) -> Result<u32, FontError>
Feature tag at index under script_tag/language_tag (\XeTeXOTfeaturetag).
Sourcepub fn opentype_math_constant(
&self,
constant: i32,
size: Length,
) -> Result<i32, FontError>
pub fn opentype_math_constant( &self, constant: i32, size: Length, ) -> Result<i32, FontError>
OpenType math constant by XeTeX and HarfBuzz constant index.
Sourcepub fn math_italic_correction(
&self,
glyph: GlyphId,
size: Length,
) -> Result<i32, FontError>
pub fn math_italic_correction( &self, glyph: GlyphId, size: Length, ) -> Result<i32, FontError>
OpenType math italic correction for a glyph, scaled to scaled points.
Sourcepub fn math_kern_at(
&self,
glyph: GlyphId,
corner: MathKernCorner,
correction_height: i32,
) -> Result<i32, FontError>
pub fn math_kern_at( &self, glyph: GlyphId, corner: MathKernCorner, correction_height: i32, ) -> Result<i32, FontError>
Evaluate one OpenType math MathKernInfo corner at a correction height in font design units.
Sourcepub fn math_variant(
&self,
glyph: GlyphId,
index: u16,
horizontal: bool,
size: Length,
) -> Result<Option<(u32, i32)>, FontError>
pub fn math_variant( &self, glyph: GlyphId, index: u16, horizontal: bool, size: Length, ) -> Result<Option<(u32, i32)>, FontError>
Return the larger OpenType math glyph variant at index, with its advance scaled to points.
Sourcepub fn math_assembly(
&self,
glyph: GlyphId,
horizontal: bool,
size: Length,
) -> Result<Vec<MathAssemblyPart>, FontError>
pub fn math_assembly( &self, glyph: GlyphId, horizontal: bool, size: Length, ) -> Result<Vec<MathAssemblyPart>, FontError>
OpenType math glyph assembly parts, each metric scaled to scaled points.
Sourcepub fn math_min_connector_overlap(&self, size: Length) -> Result<i32, FontError>
pub fn math_min_connector_overlap(&self, size: Length) -> Result<i32, FontError>
OpenType math minimum connector overlap between assembly parts, in scaled points.
Sourcepub fn points_to_units(
&self,
points: f32,
size: Length,
) -> Result<f32, FontError>
pub fn points_to_units( &self, points: f32, size: Length, ) -> Result<f32, FontError>
Convert points to font design units using XeTeX pointsToUnits in f32.
Sourcepub fn units_to_scaled(
&self,
units: i32,
size: Length,
) -> Result<i32, FontError>
pub fn units_to_scaled( &self, units: i32, size: Length, ) -> Result<i32, FontError>
Convert font design units to scaled points using XeTeX D2Fix(unitsToPoints(...)).
Sourcepub fn opentype_math_accent_position(
&self,
glyph: GlyphId,
size: Length,
) -> Result<i32, FontError>
pub fn opentype_math_accent_position( &self, glyph: GlyphId, size: Length, ) -> Result<i32, FontError>
Top accent attachment position for glyph, scaled to scaled points (\XeTeXmathaccent).