Skip to main content

Face

Struct Face 

Source
pub struct Face { /* private fields */ }
Expand description

A font face, owning its bytes.

The bytes are Arc’d and the reader is rebuilt per use rather than stored. Opening only validates a header, so this is a handful of bounds checks — cheap next to drawing a glyph, and it keeps the type free of the self-reference a borrowed FontRef<'static> would need.

Implementations§

Source§

impl Face

Source

pub fn new(bytes: Arc<[u8]>, index: u32) -> Option<Self>

Read a face from a font program.

Accepts anything with a table directory — TrueType, bare CFF, OpenType/CFF, and a TrueType Collection member by index. Returns None for a blob no backend recognises, which is the signal to fall back to pdfrum_type1 and then to substitution.

Source

pub fn units_per_em(&self) -> u16

Design units per em.

Source

pub fn num_glyphs(&self) -> u32

How many glyphs the face declares.

Source

pub fn is_truetype(&self) -> bool

Whether outlines come from a glyf table.

Source

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

The (platform, encoding) pairs the cmap table declares, in table order — which is the order every ladder scans them in.

Source

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

The glyph a code selects through charmap. Zero on any miss.

Source

pub fn name_index(&self, name: &str) -> u16

The glyph a name selects. Zero on a miss.

Source

pub fn glyph_name(&self, gid: Gid) -> Option<String>

A glyph’s own name.

Source

pub fn has_glyph_names(&self) -> bool

Whether the face carries glyph names at all.

Source

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

The PostScript name (name ID 6), falling back to the family name.

Source

pub fn is_fixed_pitch(&self) -> bool

post.isFixedPitch, or false when the table is missing.

Source

pub fn is_italic(&self) -> bool

Italic from OS/2 fsSelection, head.macStyle, or a non-zero post.italicAngle.

Source

pub fn is_bold(&self) -> bool

Bold from OS/2 fsSelection / usWeightClass >= 700, or head.macStyle.

Source

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

OS/2 sCapHeight in font units, when the table is version 2 or later.

Source

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

Unicode codepoint → glyph mappings of the Unicode cmap, with code <= max.

Sorted by codepoint. Glyph 0 (.notdef) is omitted, matching FT_Get_Next_Char’s glyph_index == 0 stop.

Trait Implementations§

Source§

impl Clone for Face

Source§

fn clone(&self) -> Face

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 Face

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Face

§

impl RefUnwindSafe for Face

§

impl Send for Face

§

impl Sync for Face

§

impl Unpin for Face

§

impl UnsafeUnpin for Face

§

impl UnwindSafe for Face

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.