Skip to main content

FontData

Struct FontData 

Source
pub struct FontData {
    pub id: FontId,
    pub canonical_name: String,
    /* private fields */
}
Expand description

Loaded font identity plus its face source.

Fields§

§id: FontId

Stable font identity.

§canonical_name: String

Canonical font family or face name.

Implementations§

Source§

impl FontData

Source

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.

Source

pub fn from_shared_face( id: FontId, canonical_name: impl Into<String>, face: Arc<dyn SharedFace>, ) -> Self

Create font data from a face the application already parsed; the library never parses it.

Source

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

Returns the raw bytes when the library owns them; None for application 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, 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, shared across clones and with shaping.

Source

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

Parse overall font metrics at the requested size.

Source

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

Return metrics for a glyph at the requested size.

Source

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.

Source

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

Look up a glyph id by Unicode codepoint.

Source

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

Look up a glyph id by glyph name.

Source

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

Report 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 OpenType layout scripts from the larger layout script list.

Source

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.

Source

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

Number of languages under script_tag, summed across OpenType layout tables.

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 OpenType layout tables.

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/language_tag (\XeTeXOTfeaturetag).

Source

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

OpenType math constant by XeTeX and HarfBuzz constant index.

Source

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

OpenType math italic correction for a glyph, scaled to scaled points.

Source

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.

Source

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.

Source

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.

Source

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

OpenType math minimum connector overlap between assembly parts, in scaled points.

Source

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

Convert points to font design units using XeTeX pointsToUnits in f32.

Source

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

Convert font design units to scaled points using XeTeX D2Fix(unitsToPoints(...)).

Source

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

Source

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

Return the symbol font parameter at parameter index, mapping to OpenType math constants.

Source

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

Return the extension font parameter at parameter index, mapping to OpenType math constants.

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.