Skip to main content

FontData

Struct FontData 

Source
pub struct FontData {
    pub key: FontKey,
    /* private fields */
}
Expand description

A loaded font face and the key the host chose for it.

Fields§

§key: FontKey

Host chosen identity, carried into the IR’s font references.

Implementations§

Source§

impl FontData

Source

pub fn new(key: FontKey, bytes: impl Into<Arc<[u8]>>) -> Self

Wraps raw font bytes, parsed lazily and at most once.

Source

pub fn from_shared_face(key: FontKey, face: Arc<dyn SharedFace>) -> Self

Wraps a face the host already parsed, the library never parses it.

Source

pub fn bytes(&self) -> Option<&Arc<[u8]>>

Returns the raw bytes the library owns, None for host shared faces.

Source

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.

Source

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.

Source

pub fn metrics(&self, size: Length) -> Result<FontMetrics, FontError>

Overall metrics at size, as XeTeX reads them for a native font.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn glyph_index(&self, codepoint: char) -> Result<Option<GlyphId>, FontError>

Looks a glyph up by Unicode code point.

Source

pub fn glyph_index_by_name( &self, name: &str, ) -> Result<Option<GlyphId>, FontError>

Looks a glyph up by glyph name.

Source

pub fn has_opentype_math(&self) -> Result<bool, FontError>

Whether the font has an OpenType math table.

Source

pub fn ot_glyph_count(&self) -> Result<u32, FontError>

Number of glyphs in the font, \XeTeXcountglyphs.

Source

pub fn ot_script_count(&self) -> Result<u32, FontError>

Number of scripts in the larger of the GSUB and GPOS script lists.

Source

pub fn ot_script_tag(&self, index: u32) -> Result<u32, FontError>

Script tag at index, packed big endian as XeTeX’s hb_tag_t.

Source

pub fn ot_language_count(&self, script_tag: u32) -> Result<u32, FontError>

Number of languages under script_tag, summed across GSUB and GPOS.

Source

pub fn ot_language_tag( &self, script_tag: u32, index: u32, ) -> Result<u32, FontError>

Language tag at index under script_tag, \XeTeXOTlanguagetag.

Source

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.

Source

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.

Source

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.

Source

pub fn math_italic_correction( &self, glyph: GlyphId, size: Length, ) -> Result<i32, FontError>

OpenType math italic correction of a glyph, in scaled points.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn math_min_connector_overlap(&self, size: Length) -> Result<i32, FontError>

Minimum connector overlap between assembly parts, in scaled points.

Source

pub fn points_to_units( &self, points: f32, size: Length, ) -> Result<f32, FontError>

Converts points to design units in f32, as XeTeX’s pointsToUnits.

Source

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)).

Source

pub fn opentype_math_accent_position( &self, glyph: GlyphId, size: Length, ) -> Result<i32, FontError>

Top accent attachment of a glyph in scaled points, \XeTeXmathaccent.

Source

pub fn math_symbol_parameter( &self, parameter: i32, size: Length, ) -> Result<i32, FontError>

Symbol font parameter mapped to OpenType math constants, as XeTeX’s get_native_mathsy_param.

Source

pub fn math_extension_parameter( &self, parameter: i32, size: Length, ) -> Result<i32, FontError>

Extension font parameter mapped to OpenType math constants, as XeTeX’s get_native_mathex_param.

Trait Implementations§

Source§

impl Clone for FontData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FontData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FontData

Source§

impl PartialEq for FontData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.