#[non_exhaustive]pub struct DataRequest<'a> {
pub lib: bool,
pub groups: bool,
pub kerning: bool,
pub features: bool,
pub data: bool,
pub images: bool,
/* private fields */
}Expand description
A type that describes which components of a UFO should be loaded.
By default, all components of the UFO file are loaded; however, if you only
need a subset of them, you can pass this struct to Ufo::with_fields in
order to only load the fields you specify. This can improve performance in
large projects.
§Examples
A DataRequest that excludes all layer, glyph and kerning data:
use norad::DataRequest;
let datareq = DataRequest::default().layers(false).kerning(false);A DataRequest that excludes all UFO data and images:
use norad::DataRequest;
let datareq = DataRequest::default().data(false).images(false);A DataRequest that only includes parsed lib.plist data:
use norad::DataRequest;
let datareq = DataRequest::none().lib(true);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.lib: boolLoad parsed lib.plist data
groups: boolLoad parsed groups.plist data
kerning: boolLoad parsed kerning.plist data
features: boolLoad Adobe .fea format feature file data
data: boolLoad data
images: boolLoad images
Implementations§
Source§impl<'a> DataRequest<'a>
impl<'a> DataRequest<'a>
Sourcepub fn all() -> Self
pub fn all() -> Self
Returns a DataRequest requesting all UFO data.
Sourcepub fn none() -> Self
pub fn none() -> Self
Returns a DataRequest requesting no UFO data.
Sourcepub fn layers(self, b: bool) -> Self
pub fn layers(self, b: bool) -> Self
Request that returned UFO data include layers and their glyph data.
See also the filter_layers and default_layer options.
Sourcepub fn default_layer(self, b: bool) -> Self
pub fn default_layer(self, b: bool) -> Self
Request to only load the default layer.
If set, we will ignore the layers option. For finer-grained control,
see the filter_layers option.
Sourcepub fn filter_layers(self, filter: impl Fn(&str, &Path) -> bool + 'a) -> Self
pub fn filter_layers(self, filter: impl Fn(&str, &Path) -> bool + 'a) -> Self
Request to load a subset of layers using a closure
Given the name and directory of a layer, the closure must return true
or false. Only layers for which the closure returns true will be loaded.
If this is set, it will override the layers option.
To only load the default layer, use the default_layer option.
§Examples
To only load the background layer:
let to_load = DataRequest::none().filter_layers(|name, _path| name.contains("background"));
let font = Font::load_requested_data("path/to/font.ufo", to_load).unwrap();Sourcepub fn groups(self, b: bool) -> Self
pub fn groups(self, b: bool) -> Self
Request that returned UFO data include parsed groups.plist.
Sourcepub fn kerning(self, b: bool) -> Self
pub fn kerning(self, b: bool) -> Self
Request that returned UFO data include parsed kerning.plist.
Sourcepub fn features(self, b: bool) -> Self
pub fn features(self, b: bool) -> Self
Request that returned UFO data include OpenType Layout features in Adobe .fea format.