Struct Compilation

Source
pub struct Compilation {
    pub head: Option<Head>,
    pub hhea: Option<Hhea>,
    pub vhea: Option<Vhea>,
    pub os2: Option<Os2>,
    pub gdef: Option<Gdef>,
    pub base: Option<Base>,
    pub name: Option<Name>,
    pub stat: Option<Stat>,
    pub gsub: Option<Gsub>,
    pub gpos: Option<Gpos>,
    pub gdef_classes: Option<HashMap<GlyphId16, GlyphClassDef>>,
    /* private fields */
}
Expand description

The tables generated by this compilation.

All tables are optional, and the set of tables that are present depends on the input file.

Each table is a type defined in the [write-fonts][] crate. The caller may either interact with these directly, or else they may use the to_binary method to generate a binary font.

Fields§

§head: Option<Head>

The head table, if one was generated

§hhea: Option<Hhea>

The hhea table, if one was generated

§vhea: Option<Vhea>

The vhea table, if one was generated

§os2: Option<Os2>

The OS/2 table, if one was generated

§gdef: Option<Gdef>

The GDEF table, if one was generated

§base: Option<Base>

The BASE table, if one was generated

§name: Option<Name>

The name table, if one was generated

§stat: Option<Stat>

The STAT table, if one was generated

§gsub: Option<Gsub>

The GSUB table, if one was generated

§gpos: Option<Gpos>

The GPOS table, if one was generated

§gdef_classes: Option<HashMap<GlyphId16, GlyphClassDef>>

Any explicit gdef classes declared in the FEA.

This is provided so that the user can reference them if they are going to manually generate kerning or markpos lookups.

Implementations§

Source§

impl Compilation

Source

pub fn has_non_layout_tables(&self) -> bool

Returns true if the FEA generated tables other than GSUB, GPOS & GDEF.

Source

pub fn remap_name_ids(&mut self, first_avail_id: u16)

Remap any NameIds in the name table and anywhere they are referenced.

This is used for merging the results of our compilation with other compilation operations which may have occured elsewhere, and which may have used the same NameIds as us for different strings.

We will take all the name ids we have declared that are >= 256 and offset them to start at first_avail_id.

Source

pub fn to_font_builder(&self) -> Result<FontBuilder<'_>, BuilderError>

Assemble the output tables into a FontBuilder.

This is a convenience method. To compile a binary font you can use to_binary instead, and for more fine-grained control you can inspect and manipulate the raw tables directly.

Source

pub fn to_binary(&self, glyph_map: &GlyphMap) -> Result<Vec<u8>, BuilderError>

Compile the output tables into a font.

This is a convenience method used for things like testing; if you are building a font compiler you will probably prefer to manipulate the generated tables directly.

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> 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<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.