Struct FontBuilder

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

Build a font from some set of tables.

Implementations§

Source§

impl<'a> FontBuilder<'a>

Source

pub fn new() -> Self

Create a new builder to compile a binary font

Source

pub fn add_table<T>(&mut self, table: &T) -> Result<&mut Self, BuilderError>

Add a table to the builder.

The table can be any top-level table defined in this crate. This function will attempt to compile the table and then add it to the builder if successful, returning an error otherwise.

Source

pub fn add_raw(&mut self, tag: Tag, data: impl Into<Cow<'a, [u8]>>) -> &mut Self

A builder method to add raw data for the provided tag

Source

pub fn copy_missing_tables(&mut self, font: FontRef<'a>) -> &mut Self

Copy each table from the source font if it does not already exist

Source

pub fn contains(&self, tag: Tag) -> bool

Returns true if the builder contains a table with this tag.

Source

pub fn ordered_tags(&self) -> Vec<Tag>

Returns the builder’s table tags in the order recommended by the OpenType spec.

Table tags not in the recommended order are sorted lexicographically, and ‘DSIG’ is always sorted last. The presence of the ‘CFF ’ table determines which of the two recommended orders is used. This matches fontTools’ sortedTagList function.

See: https://learn.microsoft.com/en-us/typography/opentype/spec/recom#optimized-table-ordering https://github.com/fonttools/fonttools/blob/8d6b2f8f87637fcad8dae498d32eae738cd951bf/Lib/fontTools/ttLib/ttFont.py#L1096-L1117

Source

pub fn build(&mut self) -> Vec<u8>

Assemble all the tables into a binary font file with a Table Directory.

Trait Implementations§

Source§

impl<'a> Clone for FontBuilder<'a>

Source§

fn clone(&self) -> FontBuilder<'a>

Returns a copy 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<'a> Debug for FontBuilder<'a>

Source§

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

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

impl<'a> Default for FontBuilder<'a>

Source§

fn default() -> FontBuilder<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FontBuilder<'a>

§

impl<'a> RefUnwindSafe for FontBuilder<'a>

§

impl<'a> Send for FontBuilder<'a>

§

impl<'a> Sync for FontBuilder<'a>

§

impl<'a> Unpin for FontBuilder<'a>

§

impl<'a> UnwindSafe for FontBuilder<'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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

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

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

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

Source§

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.