diff --git a/src/cache.rs b/src/cache.rs index 2ce63dd..1b1f359 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -2,18 +2,18 @@ use super::FontRef; /// Uniquely generated value for identifying and caching fonts. #[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)] -pub struct CacheKey(pub(crate) u64); +pub struct CacheKey(pub(crate) usize); impl CacheKey { /// Generates a new cache key. pub fn new() -> Self { - use core::sync::atomic::{AtomicU64, Ordering}; - static KEY: AtomicU64 = AtomicU64::new(1); + use core::sync::atomic::{AtomicUsize, Ordering}; + static KEY: AtomicUsize = AtomicUsize::new(1); Self(KEY.fetch_add(1, Ordering::Relaxed)) } /// Returns the underlying value of the key. - pub fn value(self) -> u64 { + pub fn value(self) -> usize { self.0 } } @@ -42,10 +42,10 @@ impl FontCache { pub fn get<'a>( &'a mut self, font: &FontRef, - id_override: Option<[u64; 2]>, + id_override: Option<[usize; 2]>, mut f: impl FnMut(&FontRef) -> T, - ) -> ([u64; 2], &'a T) { - let id = id_override.unwrap_or([font.key.value(), u64::MAX]); + ) -> ([usize; 2], &'a T) { + let id = id_override.unwrap_or([font.key.value(), usize::MAX]); let (found, index) = self.find(id); if found { let entry = &mut self.entries[index]; @@ -72,7 +72,7 @@ impl FontCache { } } - fn find(&self, id: [u64; 2]) -> (bool, usize) { + fn find(&self, id: [usize; 2]) -> (bool, usize) { let mut lowest = 0; let mut lowest_epoch = self.epoch; for (i, entry) in self.entries.iter().enumerate() { @@ -94,6 +94,6 @@ impl FontCache { struct Entry { epoch: u64, - id: [u64; 2], + id: [usize; 2], data: T, } diff --git a/src/scale/hinting_cache.rs b/src/scale/hinting_cache.rs index 83e0461..9432641 100644 --- a/src/scale/hinting_cache.rs +++ b/src/scale/hinting_cache.rs @@ -10,7 +10,7 @@ use skrifa::{ const MAX_CACHED_HINT_INSTANCES: usize = 8; pub struct HintingKey<'a> { - pub id: [u64; 2], + pub id: [usize; 2], pub outlines: &'a OutlineGlyphCollection<'a>, pub size: Size, pub coords: &'a [NormalizedCoord], @@ -58,7 +58,7 @@ impl HintingCache { } struct HintingEntry { - id: [u64; 2], + id: [usize; 2], instance: HintingInstance, serial: u64, } diff --git a/src/scale/mod.rs b/src/scale/mod.rs index ffb6ce7..5d37fdf 100644 --- a/src/scale/mod.rs +++ b/src/scale/mod.rs @@ -340,7 +340,7 @@ pub struct ScalerBuilder<'a> { font: FontRef<'a>, outlines: Option>, proxy: &'a ScalerProxy, - id: [u64; 2], + id: [usize; 2], coords: &'a mut Vec, size: f32, hint: bool, diff --git a/src/shape/cache.rs b/src/shape/cache.rs index fa6b31a..6284007 100644 --- a/src/shape/cache.rs +++ b/src/shape/cache.rs @@ -27,7 +27,7 @@ impl FontEntry { pub struct FeatureEntry { pub epoch: Epoch, - pub id: [u64; 2], + pub id: [usize; 2], pub coords: Vec, pub tags: [u32; 4], pub store: FeatureStore, @@ -55,7 +55,7 @@ impl FeatureCache { pub fn entry<'a>( &'a mut self, - id: [u64; 2], + id: [usize; 2], coords: &[i16], has_feature_vars: bool, tags: &[u32; 4], @@ -77,7 +77,7 @@ impl FeatureCache { fn find_entry( &mut self, - id: [u64; 2], + id: [usize; 2], coords: &[i16], has_feature_vars: bool, tags: &[u32; 4], diff --git a/src/shape/mod.rs b/src/shape/mod.rs index f0a0fa3..d4f0d26 100644 --- a/src/shape/mod.rs +++ b/src/shape/mod.rs @@ -318,7 +318,7 @@ impl ShapeContext { pub fn builder_with_id<'a>( &'a mut self, font: impl Into>, - id: [u64; 2], + id: [usize; 2], ) -> ShaperBuilder<'a> { ShaperBuilder::new_with_id(self, font, id) } @@ -367,7 +367,7 @@ pub struct ShaperBuilder<'a> { state: &'a mut State, feature_cache: &'a mut FeatureCache, font: FontRef<'a>, - font_id: [u64; 2], + font_id: [usize; 2], font_entry: &'a FontEntry, coords: &'a mut Vec, charmap: Charmap<'a>, @@ -384,7 +384,7 @@ impl<'a> ShaperBuilder<'a> { /// context and font. fn new(context: &'a mut ShapeContext, font: impl Into>) -> Self { let font = font.into(); - let id = [font.key.value(), u64::MAX]; + let id = [font.key.value(), usize::MAX]; Self::new_with_id(context, font, id) } @@ -393,7 +393,7 @@ impl<'a> ShaperBuilder<'a> { fn new_with_id( context: &'a mut ShapeContext, font: impl Into>, - id: [u64; 2], + id: [usize; 2], ) -> Self { let font = font.into(); let (font_id, font_entry) = context.font_cache.get(&font, Some(id), FontEntry::new); diff --git a/src/shape/partition.rs b/src/shape/partition.rs index 1bedf48..32f4f3e 100644 --- a/src/shape/partition.rs +++ b/src/shape/partition.rs @@ -24,7 +24,7 @@ pub trait SelectedFont: PartialEq { /// Returns a reference to the underlying font. fn font(&self) -> FontRef; - fn id_override(&self) -> Option<[u64; 2]> { + fn id_override(&self) -> Option<[usize; 2]> { None } @@ -215,7 +215,7 @@ where let font_ref = font.font(); let id = font .id_override() - .unwrap_or([font_ref.key.value(), u64::MAX]); + .unwrap_or([font_ref.key.value(), usize::MAX]); let mut shaper = context .builder_with_id(font.font(), id) .script(options.script())