From 948c1d8f541850b95bb6ba853dd26e32a7e61f30 Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Fri, 22 Mar 2024 11:55:09 -0400 Subject: [PATCH] [read-fonts] impl From for DeltaSetIdx This is a tiny quality-of-life improvement, since this conversion is necessary in order to get the variation data out of the data store. This also derives the standard traits for DeltaSetIndex. --- read-fonts/src/tables/layout.rs | 11 +++++++++++ read-fonts/src/tables/variations.rs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/read-fonts/src/tables/layout.rs b/read-fonts/src/tables/layout.rs index e2288e1c2..8279b6373 100644 --- a/read-fonts/src/tables/layout.rs +++ b/read-fonts/src/tables/layout.rs @@ -7,6 +7,8 @@ use core::cmp::Ordering; pub use lookupflag::LookupFlag; +use super::variations::DeltaSetIndex; + #[cfg(test)] #[path = "../tests/layout.rs"] mod spec_tests; @@ -350,6 +352,15 @@ fn iter_packed_values(raw: u16, format: DeltaFormat, n: usize) -> impl Iterator< decoded.into_iter().flatten() } +impl From> for DeltaSetIndex { + fn from(src: VariationIndex) -> DeltaSetIndex { + DeltaSetIndex { + outer: src.delta_set_outer_index(), + inner: src.delta_set_inner_index(), + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/read-fonts/src/tables/variations.rs b/read-fonts/src/tables/variations.rs index c5aceee3c..fbf644583 100644 --- a/read-fonts/src/tables/variations.rs +++ b/read-fonts/src/tables/variations.rs @@ -7,7 +7,7 @@ use super::gvar::SharedTuples; use std::iter::Skip; /// Outer and inner indices for reading from an [ItemVariationStore]. -#[derive(Copy, Clone, Debug)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DeltaSetIndex { /// Outer delta set index. pub outer: u16,