Skip to main content

FontCollection

Struct FontCollection 

Source
pub struct FontCollection<'a> { /* private fields */ }
Expand description

A parsed TTC collection: N font directories sharing table data.

Implementations§

Source§

impl<'a> FontCollection<'a>

Source

pub fn parse(data: &'a [u8]) -> Result<Self, ParseError>

Parse and validate the TTC header.

§Errors

ParseError::InvalidSfnt for a bad signature or version; ParseError::TruncatedTable when the offset array is short.

Source

pub const fn version(&self) -> u32

The TTC version (0x00010000 or 0x00020000).

Source

pub fn len(&self) -> usize

Number of fonts in the collection.

Source

pub fn is_empty(&self) -> bool

True when the collection declares no fonts.

Source

pub fn font(&self, index: usize) -> Result<FontRef<'a>, ParseError>

Font index as a zero-copy reference over the whole collection buffer (TTC table offsets are file-relative, so sharing works).

§Errors

ParseError::CollectionIndexOutOfBounds beyond the font count; ParseError::InvalidSfnt / ParseError::TruncatedTable for a malformed directory.

Source

pub fn fonts(&self) -> Result<Vec<FontRef<'a>>, ParseError>

All fonts (see font).

§Errors

First error from any font directory.

Source

pub fn fonts_in(data: &'a [u8]) -> Result<Vec<FontRef<'a>>, ParseError>

One-shot parse of a TTC buffer into font references.

§Errors

See FontCollection::parse / fonts.

Trait Implementations§

Source§

impl<'a> Clone for FontCollection<'a>

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<'a> Debug for FontCollection<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FontCollection<'a>

§

impl<'a> RefUnwindSafe for FontCollection<'a>

§

impl<'a> Send for FontCollection<'a>

§

impl<'a> Sync for FontCollection<'a>

§

impl<'a> Unpin for FontCollection<'a>

§

impl<'a> UnsafeUnpin for FontCollection<'a>

§

impl<'a> UnwindSafe for FontCollection<'a>

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.