pub struct Compiler<'a> { /* 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::new("path/to/features.fea", &glyph_map)
.verbose(true)
.compile_binary().unwrap();Implementations§
source§impl<'a> Compiler<'a>
impl<'a> Compiler<'a>
sourcepub fn new(root_path: impl Into<OsString>, glyph_map: &'a GlyphMap) -> Self
pub fn new(root_path: impl Into<OsString>, 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.
sourcepub fn with_resolver(self, resolver: impl SourceResolver + 'static) -> Self
pub fn with_resolver(self, resolver: impl SourceResolver + 'static) -> Self
Provide a custom SourceResolver, for mapping paths to their contents.
sourcepub fn with_variable_info(self, var_info: &'a dyn VariationInfo) -> Self
pub fn with_variable_info(self, var_info: &'a dyn VariationInfo) -> Self
Provide VariationInfo, necessary when compiling features for a variable font.
sourcepub fn verbose(self, verbose: bool) -> Self
👎Deprecated since 0.14.1: use print_warnings method instead
pub fn verbose(self, verbose: bool) -> Self
Specify verbosity.
When verbose is true, we will print all warnings.
sourcepub fn print_warnings(self, warnings: bool) -> Self
pub fn print_warnings(self, warnings: bool) -> Self
Indicate whether or not warnings should be printed (default is true)
sourcepub fn max_error_messages(self, max_n_errors: usize) -> Self
pub fn max_error_messages(self, max_n_errors: usize) -> Self
Specify a maximum number of messages to print when errors occur.
Default is some arbitrary ‘reasonable’ number (currently 100.) To
suppress errors, pass 0. To print all errors, pass a number as large
as the number of errors you intend to write.
sourcepub fn with_project_root(self, project_root: impl Into<PathBuf>) -> Self
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.
sourcepub fn compile(self) -> Result<Compilation, CompilerError>
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.
sourcepub fn compile_binary(self) -> Result<Vec<u8>, CompilerError>
pub fn compile_binary(self) -> Result<Vec<u8>, CompilerError>
Compile to a binary font.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Compiler<'a>
impl<'a> !Send for Compiler<'a>
impl<'a> !Sync for Compiler<'a>
impl<'a> Unpin for Compiler<'a>
impl<'a> !UnwindSafe for Compiler<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere U: FromObjRef<T>,
source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.