pub struct FontData {
pub key: FontKey,
/* private fields */
}Expand description
A loaded font face and the key the host chose for it.
Fields§
§key: FontKeyHost chosen identity, carried into the IR’s font references.
Implementations§
Source§impl FontData
impl FontData
Sourcepub fn new(key: FontKey, bytes: impl Into<Arc<[u8]>>) -> Self
pub fn new(key: FontKey, bytes: impl Into<Arc<[u8]>>) -> Self
Wraps raw font bytes, parsed lazily and at most once.
Wraps a face the host 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 the library owns, None for host 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 and 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 and shared across clones.
Sourcepub fn metrics(&self, size: Length) -> Result<FontMetrics, FontError>
pub fn metrics(&self, size: Length) -> Result<FontMetrics, FontError>
Overall metrics at size, as XeTeX reads them for a native font.
Sourcepub fn glyph_metrics(
&self,
glyph: GlyphId,
size: Length,
) -> Result<FontGlyphMetrics, FontError>
pub fn glyph_metrics( &self, glyph: GlyphId, size: Length, ) -> Result<FontGlyphMetrics, FontError>
Width, height and depth of a glyph at size, from its advance and bounding box.
Sourcepub fn glyph_bounds_points(
&self,
glyph: GlyphId,
size: Length,
) -> Result<GlyphBoundsPoints, FontError>
pub fn glyph_bounds_points( &self, glyph: GlyphId, size: Length, ) -> Result<GlyphBoundsPoints, FontError>
Advance and control box of a glyph in points at size, as XeTeX’s getGlyphBounds reads them.
Sourcepub fn char_code_range(&self) -> Result<Option<(u32, u32)>, FontError>
pub fn char_code_range(&self) -> Result<Option<(u32, u32)>, FontError>
Smallest and largest code points the Unicode cmaps map to a glyph, as FreeType’s first and last char.
Sourcepub fn glyph_outlines(
&self,
glyphs: &[GlyphId],
) -> Result<Vec<Option<GlyphOutline>>, FontError>
pub fn glyph_outlines( &self, glyphs: &[GlyphId], ) -> Result<Vec<Option<GlyphOutline>>, FontError>
Outlines in font design units with y up, one entry per glyph, None for blank glyphs.
Sourcepub fn glyph_index(&self, codepoint: char) -> Result<Option<GlyphId>, FontError>
pub fn glyph_index(&self, codepoint: char) -> Result<Option<GlyphId>, FontError>
Looks a glyph up by Unicode code point.
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>
Looks a glyph up by glyph name.
Sourcepub fn has_opentype_math(&self) -> Result<bool, FontError>
pub fn has_opentype_math(&self) -> Result<bool, FontError>
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 scripts in the larger of the GSUB and GPOS script lists.
Sourcepub fn ot_script_tag(&self, index: u32) -> Result<u32, FontError>
pub fn ot_script_tag(&self, index: u32) -> Result<u32, FontError>
Script tag at index, packed big endian as XeTeX’s hb_tag_t.
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 GSUB and GPOS.
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 GSUB and GPOS.
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 and 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 index, in scaled points or percent.
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 of a glyph, in scaled points.
Sourcepub fn math_kern_at(
&self,
glyph: GlyphId,
corner: MathKernCorner,
correction_height: i32,
size: Length,
) -> Result<i32, FontError>
pub fn math_kern_at( &self, glyph: GlyphId, corner: MathKernCorner, correction_height: i32, size: Length, ) -> Result<i32, FontError>
One MathKernInfo corner at a correction height in scaled points, in scaled points.
Sourcepub fn math_kern_units(
&self,
glyph: GlyphId,
corner: MathKernCorner,
correction_height: i32,
) -> Result<i32, FontError>
pub fn math_kern_units( &self, glyph: GlyphId, corner: MathKernCorner, correction_height: i32, ) -> Result<i32, FontError>
One MathKernInfo corner in font design units, XeTeX sums kerns in these units before scaling.
Sourcepub fn math_variant(
&self,
glyph: GlyphId,
index: u16,
horizontal: bool,
size: Length,
) -> Result<Option<MathVariant>, FontError>
pub fn math_variant( &self, glyph: GlyphId, index: u16, horizontal: bool, size: Length, ) -> Result<Option<MathVariant>, FontError>
The larger math glyph variant at index, None past the last one.
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>
Math glyph assembly parts, measurements in scaled points, empty when the glyph has none.
Sourcepub fn math_min_connector_overlap(&self, size: Length) -> Result<i32, FontError>
pub fn math_min_connector_overlap(&self, size: Length) -> Result<i32, FontError>
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>
Converts points to design units in f32, as XeTeX’s pointsToUnits.
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>
Converts design units to scaled points, as XeTeX’s D2Fix(unitsToPoints(units)).
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 of a glyph in scaled points, \XeTeXmathaccent.