diff --git a/examples/text/src/font/cache.rs b/examples/text/src/font/cache.rs index 505e48ea..b99dc73c 100644 --- a/examples/text/src/font/cache.rs +++ b/examples/text/src/font/cache.rs @@ -1,24 +1,24 @@ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct CacheKey { + pub glyph_id: u16, + pub font_size: i32, pub x_bin: SubpixelBin, pub y_bin: SubpixelBin, - pub font_size: i32, - pub glyph_id: u16, } impl CacheKey { - pub fn new(pos: (f32, f32), font_size: i32, glyph_id: u16) -> (i32, i32, Self) { + pub fn new(glyph_id: u16, font_size: i32, pos: (f32, f32)) -> (Self, i32, i32) { let (x, x_bin) = SubpixelBin::new(pos.0); let (y, y_bin) = SubpixelBin::new(pos.1); ( - x, - y, Self { + glyph_id, + font_size, x_bin, y_bin, - font_size, - glyph_id, - } + }, + x, + y, ) } } diff --git a/examples/text/src/font/layout.rs b/examples/text/src/font/layout.rs index 231a30b7..31210fb1 100644 --- a/examples/text/src/font/layout.rs +++ b/examples/text/src/font/layout.rs @@ -11,7 +11,7 @@ pub struct FontLayoutGlyph<'a> { #[cfg(feature = "rusttype")] pub inner: rusttype::PositionedGlyph<'a>, #[cfg(feature = "swash")] - pub inner: (i32, i32, CacheKey), + pub inner: (CacheKey, i32, i32), } pub struct FontLayoutLine<'a> { @@ -56,7 +56,7 @@ impl<'a> FontLayoutLine<'a> { let mut cache = glyph.font.cache.lock().unwrap(); - let (x_int, y_int, cache_key) = glyph.inner; + let (cache_key, x_int, y_int) = glyph.inner; let image_opt = cache.entry(cache_key).or_insert_with(|| { let mut scale_context = glyph.font.scale_context.lock().unwrap(); diff --git a/examples/text/src/font/shape.rs b/examples/text/src/font/shape.rs index 9f50c154..cc3fe2ad 100644 --- a/examples/text/src/font/shape.rs +++ b/examples/text/src/font/shape.rs @@ -46,9 +46,9 @@ impl<'a> FontShapeGlyph<'a> { #[cfg(feature = "swash")] let inner = CacheKey::new( - (x + x_offset, y - y_offset), + self.inner, font_size, - self.inner + (x + x_offset, y - y_offset), ); FontLayoutGlyph {