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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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>

source

pub fn all() -> Self

Returns a DataRequest requesting all UFO data.

source

pub fn none() -> Self

Returns a DataRequest requesting no UFO data.

source

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.

source

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.

source

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();
source

pub fn lib(self, b: bool) -> Self

Request that returned UFO data include <lib> sections.

source

pub fn groups(self, b: bool) -> Self

Request that returned UFO data include parsed groups.plist.

source

pub fn kerning(self, b: bool) -> Self

Request that returned UFO data include parsed kerning.plist.

source

pub fn features(self, b: bool) -> Self

Request that returned UFO data include OpenType Layout features in Adobe .fea format.

source

pub fn data(self, b: bool) -> Self

Request that returned UFO data include data.

source

pub fn images(self, b: bool) -> Self

Request that returned UFO data include images.

Trait Implementations§

source§

impl<'a> Debug for DataRequest<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DataRequest<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DataRequest<'a>

§

impl<'a> !RefUnwindSafe for DataRequest<'a>

§

impl<'a> !Send for DataRequest<'a>

§

impl<'a> !Sync for DataRequest<'a>

§

impl<'a> Unpin for DataRequest<'a>

§

impl<'a> !UnwindSafe for DataRequest<'a>

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.