Skip to content

Commit

Permalink
[read-fonts] impl From<VariationIdx> for DeltaSetIdx
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmyr committed Mar 22, 2024
1 parent db35434 commit 948c1d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions read-fonts/src/tables/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -350,6 +352,15 @@ fn iter_packed_values(raw: u16, format: DeltaFormat, n: usize) -> impl Iterator<
decoded.into_iter().flatten()
}

impl From<VariationIndex<'_>> 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::*;
Expand Down
2 changes: 1 addition & 1 deletion read-fonts/src/tables/variations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 948c1d8

Please sign in to comment.