Skip to main content

SharedFont

Struct SharedFont 

Source
pub(super) struct SharedFont(Arc<SharedFontRepr>);
Expand description

The state every instance of a font shares.

Reference counted internally: cloning it costs no more than the count, and it is thread safe.

Tuple Fields§

§0: Arc<SharedFontRepr>

Implementations§

Source§

impl SharedFont

Source

fn new(source: impl Into<Source>, index: u32) -> Option<Self>

Creates a new font from the given source and font index.

See Font::new for how index is used.

Source

fn source(&self) -> &Source

Returns the underlying source of font data.

Source

pub(super) fn kind(&self) -> Kind<'_>

Returns the underlying kind of the font.

Source

fn multiple_master(&self) -> Option<&MultipleMaster>

Returns the design space of a Type 1 multiple master font.

Source

fn type1_axes(&self) -> &[VariationAxisRecord]

Returns the axes of a Type 1 multiple master font, which is empty for any other font.

Source

fn metrics(&self) -> &Metrics

Returns the metrics describing the font as a whole, at its default location.

Source

fn style_metrics(&self) -> &StyleMetrics

Returns the style measurements at the font’s default location.

Source

pub(super) fn num_glyphs(&self) -> u32

Returns the number of glyphs in the font.

Fixed for the font: no location varies it.

Source

fn units_per_em(&self) -> u16

Returns the size of the em square, in font units.

Fixed for the font: no location varies it.

Source

pub(super) fn sfnt(&self) -> Option<&SfntCaches>

Returns the caches of an SFNT font, or None for a font of another kind.

Source

fn tables_arc(&self) -> Option<&Arc<Tables>>

Returns the tables behind this font, for a cache that holds them.

Source

pub(super) fn unicode_charmap(&self) -> Option<&SfntUnicodeCharmap<'_>>

Returns the selected character maps, parsed once for the font.

Source

pub(super) fn encodings(&self) -> Option<&EncodingTables<'_>>

Returns all selectable cmap subtables, parsed on first use.

Source

pub(super) fn standalone_cff_unicode_charmap(&self) -> Option<&UnicodeCharmap>

Source

fn h_metric_records(&self) -> &GlyphMetricRecords<'_>

Returns the horizontal glyph metrics, parsed once for the font.

Source

fn v_metric_records(&self) -> &GlyphMetricRecords<'_>

Returns the vertical glyph metrics, parsed once for the font.

Read on demand, unlike the horizontal metrics: most text is horizontal and never asks.

Source

fn selected_glyf_loca(&self) -> Option<&(Glyf<'_>, Loca<'_>)>

Returns the outline tables, parsed once for the font.

Outlines and metrics in both directions read these, so they are shared rather than parsed by each.

Source

fn hvar(&self) -> Option<&Hvar<'_>>

Returns HVAR, parsed once for the font.

Source

fn vvar(&self) -> Option<&Vvar<'_>>

Returns VVAR, parsed once for the font.

Source

fn selected_gvar(&self) -> Option<&SelectedGvar<'_>>

Returns GVAR, or gvar without it, parsed once for the font.

Typically about half a variable font, so nothing should ask for this that another table can answer.

Source

fn vorg(&self) -> Option<&Vorg<'_>>

Returns VORG, parsed once for the font.

Source

fn cff2(&self) -> Option<&CffFontRef<'_>>

Returns the CFF2 charstring outlines, parsed once for the font.

Reading one means running it, so nothing here is parsed per glyph beyond what a charstring itself needs.

Source

fn cff(&self) -> Option<&CffFontRef<'_>>

Returns the CFF charstring outlines, parsed once for the font.

Source

fn standalone_cff(&self) -> Option<&CffFontRef<'_>>

Source

fn cid_glyphs(&self) -> Option<&[u16]>

Returns the glyph for each CID of a standalone CID-keyed font, built once.

As in FreeType, the table ends at the largest CID and the first glyph with a CID is kept.

Source

fn standalone_cff_subfonts(&self) -> Option<&[Option<Subfont>]>

Source

fn varc_outlines(&self) -> Option<&Outlines<'_>>

Returns the variable composites, read once for the font.

Source

fn colr_tables(&self) -> Option<&ColrTables<'_>>

Returns COLR with its variation tables, read once for the font.

Source

fn cpal(&self) -> Option<&Cpal<'_>>

Returns CPAL, read once for the font.

Source

fn sbix(&self) -> Option<&Sbix<'_>>

Returns sbix, read once for the font.

Source

fn cbdt(&self) -> Option<&(Cblc<'_>, Cbdt<'_>)>

Returns CBLC and CBDT, read once for the font.

Source

fn ebdt(&self) -> Option<&(Eblc<'_>, Ebdt<'_>)>

Returns EBLC and EBDT, read once for the font.

Source

fn tables(&self) -> &Tables

Returns an object that provides access to individual font tables.

For non-SFNT fonts, this will return an empty set of tables.

Trait Implementations§

Source§

impl Clone for SharedFont

Source§

fn clone(&self) -> SharedFont

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

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> ErasedDestructor for T
where T: 'static,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.