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>
impl<'a, F: FeatureProvider, V: VariationInfo> Compiler<'a, F, V>
Sourcepub fn new(root_path: impl Into<PathBuf>, glyph_map: &'a GlyphMap) -> Self
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.
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 V) -> Self
pub fn with_variable_info(self, var_info: &'a V) -> Self
Provide VariationInfo
, necessary when compiling features for a variable font.
Sourcepub fn with_feature_writer(self, feature_writer: &'a F) -> Self
pub fn with_feature_writer(self, feature_writer: &'a F) -> Self
Provide FeatureProvider
to provide additional features during compilation
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 false
)
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, 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> 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.