pub struct Axes<'a> {
records: &'a [VariationAxisRecord],
}Expand description
A collection of variation axes.
This is empty if the font is not variable.
Fields§
§records: &'a [VariationAxisRecord]Implementations§
Source§impl<'a> Axes<'a>
impl<'a> Axes<'a>
Sourcepub fn get_by_tag(&self, tag: Tag) -> Option<Axis>
pub fn get_by_tag(&self, tag: Tag) -> Option<Axis>
Returns the first axis with the given tag.
Sourcepub fn filter<V>(
&self,
variations: V,
) -> impl Iterator<Item = Variation> + Clone
pub fn filter<V>( &self, variations: V, ) -> impl Iterator<Item = Variation> + Clone
Returns the values in variations that apply to these axes.
The rules are the same as those used when building a font instance:
- A variation for an axis the font does not have is dropped.
- If an axis is given more than once, the last value is used.
- Each value is clamped to the range of its axis.
The result is in the font’s axis order and contains only the axes that were given.
// For a font with one `wght` axis from 100 to 900:
let filtered: Vec<_> = font
.axes()
.filter([("wght", 400.0), ("opsz", 100.0), ("wght", 1200.0)])
.collect();
assert_eq!(filtered, [Variation::new(Tag::new(b"wght"), 900.0)]);Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Axes<'a>
impl<'a> RefUnwindSafe for Axes<'a>
impl<'a> Send for Axes<'a>
impl<'a> Sync for Axes<'a>
impl<'a> Unpin for Axes<'a>
impl<'a> UnsafeUnpin for Axes<'a>
impl<'a> UnwindSafe for Axes<'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
Mutably borrows from an owned value. Read more