Struct norad::DataRequest
source · #[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: bool
Load parsed lib.plist data
groups: bool
Load parsed groups.plist data
kerning: bool
Load parsed kerning.plist data
features: bool
Load Adobe .fea format feature file data
data: bool
Load data
images: bool
Load 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.