Skip to main content

Font

Enum Font 

Source
pub enum Font {
    Base14(Base14Font),
    Embedded(EmbeddedFontId),
}
Expand description

A renderable font – either one of the Adobe Core 14 (no data embedded; outlines from the PDF reader) or a bundled TrueType cut (data embedded, subset per-document).

§Examples

use mos_fonts::{Base14Font, Font};

let font = Font::Base14(Base14Font::Helvetica);

assert_eq!(font.pdf_base_name(), "Helvetica");

Variants§

§

Base14(Base14Font)

A Base14 face. Layout uses AFM metrics; PDF emit uses WinAnsiEncoding + per-document /Differences.

§

Embedded(EmbeddedFontId)

A bundled embedded face. Layout uses rustybuzz shaping; PDF emit produces a Type 0 CID font with /ToUnicode.

Implementations§

Source§

impl Font

Source

pub const ALL_BASE14: [Self; 14]

All 14 Base14 faces in Mosaic’s PDF-resource order (F1..F14).

Page resource dictionaries always enumerate these – even when unused – so a Base14-only document’s byte output stays stable across runs. Embedded faces are added on top, per-document.

The ordering is decoupled from Base14Font::ALL: the four pre-existing layout faces keep their historical F1..F4 resource numbers so existing integration goldens don’t shift.

Source

pub const fn base14(self) -> Option<Base14Font>

If this is a Base14 face, return the underlying variant.

§Examples
use mos_fonts::{Base14Font, Font};

let font = Font::Base14(Base14Font::Courier);

assert_eq!(font.base14(), Some(Base14Font::Courier));
Source

pub const fn embedded(self) -> Option<EmbeddedFontId>

If this is an embedded face, return its bundled id.

§Examples
use mos_fonts::{EmbeddedFontId, Font};

let font = Font::Embedded(EmbeddedFontId::Bold);

assert_eq!(font.embedded(), Some(EmbeddedFontId::Bold));
Source

pub fn pdf_base_name(self) -> &'static str

PDF /BaseFont name for Base14 (e.g. "Helvetica-BoldOblique") or the embedded face’s PostScript name. The embedded path also gets a six-letter subset tag in the actual PDF emission, but that belongs to the per-document subset, not the bundled cut.

§Examples
use mos_fonts::{Base14Font, Font};

let font = Font::Base14(Base14Font::HelveticaBoldOblique);

assert_eq!(font.pdf_base_name(), "Helvetica-BoldOblique");
Source

pub fn pdf_resource_name(self) -> &'static [u8]

Stable per-resource name (F1..F14 for Base14, F15..F20 for embedded). Page font dictionaries map these to indirect font refs.

§Examples
use mos_fonts::{Base14Font, Font};

let font = Font::Base14(Base14Font::Helvetica);

assert_eq!(font.pdf_resource_name(), b"F1");
Source

fn base14_resource_name(self) -> &'static [u8]

Internal: Base14-only resource name table (F1..F14). Kept as a method on Font rather than on Base14Font so the lookup reads the same way the enum dispatch does. The Embedded arm is handled at the caller (pdf_resource_name) so this private helper never sees it.

Trait Implementations§

Source§

impl Clone for Font

Source§

fn clone(&self) -> Font

Returns a duplicate of the value. Read more
1.0.0 · 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
Source§

impl From<Base14Font> for Font

Source§

fn from(f: Base14Font) -> Self

Converts to this type from the input type.
Source§

impl From<EmbeddedFontId> for Font

Source§

fn from(id: EmbeddedFontId) -> Self

Converts to this type from the input type.
Source§

impl Hash for Font

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Font

Source§

fn eq(&self, other: &Font) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Font

Source§

impl Eq for Font

Source§

impl StructuralPartialEq for Font

Auto Trait Implementations§

§

impl Freeze 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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

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.