Skip to main content

EmbeddedFontId

Enum EmbeddedFontId 

Source
pub enum EmbeddedFontId {
    Regular,
    Bold,
    Italic,
    BoldItalic,
    Mono,
    Math,
}
Expand description

Stable identifier for each bundled embedded cut. Used as the enum payload of Font::Embedded so Font stays Copy/Hash/Eq without resorting to pointer identity.

The crate ships three bundled families today: Noto Sans (four style cuts – Regular/Bold/Italic/BoldItalic) for proportional body text, Noto Sans Mono (one cut – Mono) for `raw` runs, and Noto Sans Math (one cut – Math) as the per-glyph fallback for math operators when the primary face doesn’t cover them. The flat-enum shape is deliberate at this scale – when a fourth family lands the right move is restructuring to { family, cut } rather than expanding this enum variant-by-variant further.

§Examples

use mos_fonts::EmbeddedFontId;

let id = EmbeddedFontId::Regular;

assert_eq!(id.pdf_resource_index(), 15);

Variants§

§

Regular

Noto Sans Regular.

§

Bold

Noto Sans Bold.

§

Italic

Noto Sans Italic.

§

BoldItalic

Noto Sans Bold Italic.

§

Mono

Noto Sans Mono Regular. The crate’s monospace face for raw runs.

§

Math

Noto Sans Math Regular. The crate’s math face – covers <= >= != sqrt partial sum delta diamond minus and broader Unicode math. Used as the default fallback target on crate::FontFamily::noto_sans so math codepoints route through it when shaping yields .notdef against the primary face.

Implementations§

Source§

impl EmbeddedFontId

Source

pub const ALL: [EmbeddedFontId; 6]

All bundled embedded cuts in a stable order. Used by the PDF backend to enumerate /Font resource entries deterministically.

Source

pub fn data(self) -> &'static EmbeddedFont

Resolve to the bundled EmbeddedFont data. Initialised on first use; subsequent calls return the same &'static reference.

§Examples
use mos_fonts::EmbeddedFontId;

let data = EmbeddedFontId::Regular.data();

assert_eq!(data.postscript_name, "NotoSans");
Source

pub const fn pdf_resource_index(self) -> u8

PDF resource-name index n for Fn. F1..F14 are reserved for the 14 Base14 fonts (see mos-pdf’s Base14 resource layout); embedded cuts use F15..=F255. The number is stable per variant forever – never re-number for byte-stability. Adding a new bundled cut is one match arm here plus a RESOURCE_NAMES-table lookup; the 256-entry table in $OUT_DIR/resource_names.rs is generated by build.rs and already accommodates F20..=F255 with no per-variant churn.

§Examples
use mos_fonts::EmbeddedFontId;

assert_eq!(EmbeddedFontId::Math.pdf_resource_index(), 20);
Source

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

PDF resource name (b"F<n>") for this cut. Backed by a baked [&[u8]; 256] LUT generated at build time so future variants only need to pick an unused index above and the name resolves automatically.

§Examples
use mos_fonts::EmbeddedFontId;

assert_eq!(EmbeddedFontId::Regular.pdf_resource_name(), b"F15");

Trait Implementations§

Source§

impl Clone for EmbeddedFontId

Source§

fn clone(&self) -> EmbeddedFontId

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 EmbeddedFontId

Source§

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

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

impl From<EmbeddedFontId> for Font

Source§

fn from(id: EmbeddedFontId) -> Font

Converts to this type from the input type.
Source§

impl Hash for EmbeddedFontId

Source§

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

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 Ord for EmbeddedFontId

Source§

fn cmp(&self, other: &EmbeddedFontId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for EmbeddedFontId

Source§

fn eq(&self, other: &EmbeddedFontId) -> 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 PartialOrd for EmbeddedFontId

Source§

fn partial_cmp(&self, other: &EmbeddedFontId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for EmbeddedFontId

Source§

impl Eq for EmbeddedFontId

Source§

impl StructuralPartialEq for EmbeddedFontId

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

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.