From 79ecc22366a12d2d516648cc5abdeba609910fe8 Mon Sep 17 00:00:00 2001 From: Taj Pereira Date: Sun, 22 Dec 2024 06:20:14 +0900 Subject: [PATCH] Add `get_outline_commands_uncached` --- src/swash.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/swash.rs b/src/swash.rs index 7c35ce9f5d..10b346f834 100644 --- a/src/swash.rs +++ b/src/swash.rs @@ -65,7 +65,7 @@ fn swash_outline_commands( font_system: &mut FontSystem, context: &mut ScaleContext, cache_key: CacheKey, -) -> Option> { +) -> Option> { use swash::zeno::PathData as _; let font = match font_system.get_font(cache_key.font_id) { @@ -98,7 +98,7 @@ fn swash_outline_commands( pub struct SwashCache { context: ScaleContext, pub image_cache: HashMap>, - pub outline_command_cache: HashMap>>, + pub outline_command_cache: HashMap>>, } impl fmt::Debug for SwashCache { @@ -137,6 +137,7 @@ impl SwashCache { .or_insert_with(|| swash_image(font_system, &mut self.context, cache_key)) } + /// Creates outline commands pub fn get_outline_commands( &mut self, font_system: &mut FontSystem, @@ -148,6 +149,15 @@ impl SwashCache { .as_deref() } + /// Creates outline commands, without caching results + pub fn get_outline_commands_uncached( + &mut self, + font_system: &mut FontSystem, + cache_key: CacheKey, + ) -> Option> { + swash_outline_commands(font_system, &mut self.context, cache_key) + } + /// Enumerate pixels in an Image, use `with_image` for better performance pub fn with_pixels( &mut self,