Struct Compiler

Source
pub struct Compiler<'a, F: FeatureProvider, V: VariationInfo> { /* private fields */ }
Expand description

A builder-style entry point for the compiler.

This is intended as the principal public API for this crate.

let glyph_map = make_glyph_map();
let my_font_bytes = Compiler::<'_, NopFeatureProvider, NopVariationInfo>::new("path/to/features.fea", &glyph_map)
    .verbose(true)
    .compile_binary().unwrap();

Implementations§

Source§

impl<'a, F: FeatureProvider, V: VariationInfo> Compiler<'a, F, V>

Source

pub fn new(root_path: impl Into<PathBuf>, glyph_map: &'a GlyphMap) -> Self

Configure a new compilation run with a root source and a glyph map.

In the general case, root_path will be a path to a feature file on disk; however you may compile from memory by passing a custom SourceResolver to the with_resolver method, in which case root_path can be any identifier that your resolver will resolve.

Source

pub fn with_resolver(self, resolver: impl SourceResolver + 'static) -> Self

Provide a custom SourceResolver, for mapping paths to their contents.

Source

pub fn with_variable_info(self, var_info: &'a V) -> Self

Provide VariationInfo, necessary when compiling features for a variable font.

Source

pub fn with_feature_writer(self, feature_writer: &'a F) -> Self

Provide FeatureProvider to provide additional features during compilation

Source

pub fn verbose(self, verbose: bool) -> Self

👎Deprecated since 0.14.1: use print_warnings method instead

Specify verbosity.

When verbose is true, we will print all warnings.

Source

pub fn print_warnings(self, warnings: bool) -> Self

Indicate whether or not warnings should be printed (default is false)

Source

pub fn with_project_root(self, project_root: impl Into<PathBuf>) -> Self

Specify an explicit project root.

This is useful in cases where import resolution is based on an explicit base directory, such as when dealing with certain source formats.

Source

pub fn with_opts(self, opts: Opts) -> Self

Specify additional compiler options.

Source

pub fn compile(self) -> Result<Compilation, CompilerError>

Parse, validate and compile this source.

This returns a Compilation object that contains all of the features and lookups generated during compilation. If you would like to go directly to a binary font, you can use compile_binary instead.

Source

pub fn compile_binary(self) -> Result<Vec<u8>, CompilerError>

Compile to a binary font.

Auto Trait Implementations§

§

impl<'a, F, V> Freeze for Compiler<'a, F, V>

§

impl<'a, F, V> !RefUnwindSafe for Compiler<'a, F, V>

§

impl<'a, F, V> !Send for Compiler<'a, F, V>

§

impl<'a, F, V> !Sync for Compiler<'a, F, V>

§

impl<'a, F, V> Unpin for Compiler<'a, F, V>

§

impl<'a, F, V> !UnwindSafe for Compiler<'a, F, V>

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.