Skip to main content

GlyphSource

Enum GlyphSource 

Source
pub enum GlyphSource {
    Fontations(Face),
    Type1(Arc<Type1Font>),
    None,
}
Expand description

Where glyphs come from.

Fontations covers TrueType, bare CFF, OpenType and everything else with a table directory; Type1 covers PFA/PFB programs and the two Multiple-Master fallback faces; None is a Type3 font or a program nothing could read.

Variants§

§

Fontations(Face)

A face read by skrifa, over bytes this value owns.

§

Type1(Arc<Type1Font>)

A Type 1 program, optionally instantiated at design coordinates.

§

None

No glyphs at all.

Implementations§

Source§

impl GlyphSource

Source

pub fn from_bytes(bytes: impl Into<Arc<[u8]>>) -> Option<Self>

Open a TrueType, OpenType, bare-CFF, or Type 1 program from its bytes.

None when no backend recognises the blob.

Source

pub fn units_per_em(&self) -> u16

Design units per em; 0 when there is no face.

Source

pub fn num_glyphs(&self) -> u32

How many glyphs the face declares.

Source

pub fn is_truetype(&self) -> bool

Is this a TrueType-shaped face? PDFium’s per-glyph fallback and its ShouldUseFont test both branch on it.

Source

pub fn char_index(&self, charmap: Charmap, code: u32) -> u16

The glyph a character code selects through the face’s currently selected charmap.

Returns 0 rather than None on a miss, because every ladder in the former working note and the former working note tests != 0 and 0 is .notdef either way.

Source

pub fn charmaps(&self) -> Vec<CharmapId>

The charmaps the face declares, as (platform, encoding) pairs in table order.

Source

pub fn default_advance(&self, gid: Gid) -> i32

Advance in 1000/em units at the face’s default location.

Source

pub fn postscript_name(&self) -> Option<String>

PostScript name, or a family/style display name, when the face has one.

Source

pub fn is_fixed_pitch(&self) -> bool

Fixed pitch: post.isFixedPitch, or Type 1 /isFixedPitch.

Source

pub fn is_italic(&self) -> bool

Italic: OS/2 / macStyle / post.italicAngle, or a Type 1 /ItalicAngle.

Source

pub fn is_bold(&self) -> bool

Bold: OS/2 / macStyle, or a Type 1 name containing Bold / Black.

Source

pub fn cap_height_unscaled(&self) -> Option<f32>

OS/2 sCapHeight in font units, when present.

Source

pub fn unscaled_ascent(&self) -> Option<i32>

Ascender in font units (hhea, or the Type 1 bbox top).

Source

pub fn unscaled_descent(&self) -> Option<i32>

Descender in font units (hhea, or the Type 1 bbox bottom).

Source

pub fn unscaled_bbox(&self) -> Option<(i32, i32, i32, i32)>

Font bounding box in font units, (left, bottom, right, top).

Source

pub fn unicode_mappings(&self, max: u32) -> Vec<(u32, u16)>

Unicode → glyph mappings with code <= max, sorted by codepoint.

A miss is omitted rather than recorded as glyph 0.

Trait Implementations§

Source§

impl Clone for GlyphSource

Source§

fn clone(&self) -> GlyphSource

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 GlyphSource

Source§

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

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

impl Default for GlyphSource

Source§

fn default() -> GlyphSource

Returns the “default value” for a type. 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.