skrifa/outline/glyf/hint/
cvt.rs
1use super::{cow_slice::CowSlice, error::HintErrorKind, F26Dot6};
4
5pub struct Cvt<'a>(CowSlice<'a>);
10
11impl Cvt<'_> {
12 pub fn get(&self, index: usize) -> Result<F26Dot6, HintErrorKind> {
13 self.0
14 .get(index)
15 .map(F26Dot6::from_bits)
16 .ok_or(HintErrorKind::InvalidCvtIndex(index))
17 }
18
19 pub fn set(&mut self, index: usize, value: F26Dot6) -> Result<(), HintErrorKind> {
20 self.0
21 .set(index, value.to_bits())
22 .ok_or(HintErrorKind::InvalidCvtIndex(index))
23 }
24
25 pub fn len(&self) -> usize {
26 self.0.len()
27 }
28}
29
30impl<'a> From<CowSlice<'a>> for Cvt<'a> {
31 fn from(value: CowSlice<'a>) -> Self {
32 Self(value)
33 }
34}