From 81cc65ca015d7e58d7452d82f2598dad51076eea Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 24 Oct 2022 11:47:49 -0600 Subject: [PATCH] Store font ID with CacheKey --- src/font/cache.rs | 4 +++- src/font/shape.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/font/cache.rs b/src/font/cache.rs index fa34214..c2e9220 100644 --- a/src/font/cache.rs +++ b/src/font/cache.rs @@ -1,5 +1,6 @@ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct CacheKey { + pub font_id: fontdb::ID, pub glyph_id: u16, pub font_size: i32, pub x_bin: SubpixelBin, @@ -7,11 +8,12 @@ pub struct CacheKey { } impl CacheKey { - pub fn new(glyph_id: u16, font_size: i32, pos: (f32, f32)) -> (Self, i32, i32) { + pub fn new(font_id: fontdb::ID, 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); ( Self { + font_id, glyph_id, font_size, x_bin, diff --git a/src/font/shape.rs b/src/font/shape.rs index 9c53ba4..30dab4c 100644 --- a/src/font/shape.rs +++ b/src/font/shape.rs @@ -17,7 +17,7 @@ impl<'a> FontShapeGlyph<'a> { let y_offset = font_size as f32 * self.y_offset; let x_advance = font_size as f32 * self.x_advance; - let inner = CacheKey::new(self.inner, font_size, (x + x_offset, y - y_offset)); + let inner = CacheKey::new(self.font.info.id, self.inner, font_size, (x + x_offset, y - y_offset)); FontLayoutGlyph { start: self.start, end: self.end,