Skip to main content

Font

Enum Font 

Source
pub enum Font {
    Builtin {
        encoding: Encoding,
    },
    TrueType {
        encoding: Encoding,
        data: Vec<u8>,
    },
}
Expand description

A resolved font ready to place glyphs.

Variants§

§

Builtin

The built-in fallback: a 5×7 bitmap alphabet, used when the document carries no usable font program (all of the base-14 cases).

Fields

§encoding: Encoding

Code → character table.

§

TrueType

An embedded TrueType program.

Fields

§encoding: Encoding

Code → character table.

§data: Vec<u8>

The font program, still compressed in the PDF sense is not our business: this is the decoded /FontFile2.

Implementations§

Source§

impl Font

Source

pub fn builtin(encoding: Encoding) -> Self

The built-in fallback with an encoding.

Source

pub fn true_type(encoding: Encoding, data: Vec<u8>) -> Option<Self>

An embedded TrueType program, rejected when it cannot be parsed.

Source

pub fn glyph(&self, code: u8) -> Option<Glyph>

The outline and advance for a byte code, or None when there is no glyph for it.

Source

pub fn advance(&self, code: u8) -> f64

The advance of a code in em units, falling back to the built-in metric.

Source

pub fn glyph_by_id(&self, id: u16) -> Option<Glyph>

The outline for a glyph id, which is how composite (Type 0) fonts select glyphs: a CID maps to an id through /CIDToGIDMap, not through a cmap.

The built-in bitmap alphabet has no glyph ids, so it has no answer here.

Trait Implementations§

Source§

impl Clone for Font

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 Font

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Font

§

impl Freeze for Font

§

impl Move for Font

§

impl RefUnwindSafe for Font

§

impl Send for Font

§

impl Sync for Font

§

impl Unpin for Font

§

impl UnsafeUnpin for Font

§

impl UnwindSafe for Font

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> Same for T

Source§

type Output = T

Should always be Self
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.