Add get_outline_commands_uncached
This commit is contained in:
parent
829a59bd95
commit
81c9666eaa
1 changed files with 12 additions and 2 deletions
14
src/swash.rs
14
src/swash.rs
|
|
@ -65,7 +65,7 @@ fn swash_outline_commands(
|
||||||
font_system: &mut FontSystem,
|
font_system: &mut FontSystem,
|
||||||
context: &mut ScaleContext,
|
context: &mut ScaleContext,
|
||||||
cache_key: CacheKey,
|
cache_key: CacheKey,
|
||||||
) -> Option<Vec<swash::zeno::Command>> {
|
) -> Option<Box<[swash::zeno::Command]>> {
|
||||||
use swash::zeno::PathData as _;
|
use swash::zeno::PathData as _;
|
||||||
|
|
||||||
let font = match font_system.get_font(cache_key.font_id) {
|
let font = match font_system.get_font(cache_key.font_id) {
|
||||||
|
|
@ -98,7 +98,7 @@ fn swash_outline_commands(
|
||||||
pub struct SwashCache {
|
pub struct SwashCache {
|
||||||
context: ScaleContext,
|
context: ScaleContext,
|
||||||
pub image_cache: HashMap<CacheKey, Option<SwashImage>>,
|
pub image_cache: HashMap<CacheKey, Option<SwashImage>>,
|
||||||
pub outline_command_cache: HashMap<CacheKey, Option<Vec<swash::zeno::Command>>>,
|
pub outline_command_cache: HashMap<CacheKey, Option<Box<[swash::zeno::Command]>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for SwashCache {
|
impl fmt::Debug for SwashCache {
|
||||||
|
|
@ -137,6 +137,7 @@ impl SwashCache {
|
||||||
.or_insert_with(|| swash_image(font_system, &mut self.context, cache_key))
|
.or_insert_with(|| swash_image(font_system, &mut self.context, cache_key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates outline commands
|
||||||
pub fn get_outline_commands(
|
pub fn get_outline_commands(
|
||||||
&mut self,
|
&mut self,
|
||||||
font_system: &mut FontSystem,
|
font_system: &mut FontSystem,
|
||||||
|
|
@ -148,6 +149,15 @@ impl SwashCache {
|
||||||
.as_deref()
|
.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates outline commands, without caching results
|
||||||
|
pub fn get_outline_commands_uncached(
|
||||||
|
&mut self,
|
||||||
|
font_system: &mut FontSystem,
|
||||||
|
cache_key: CacheKey,
|
||||||
|
) -> Option<Box<[swash::zeno::Command]>> {
|
||||||
|
swash_outline_commands(font_system, &mut self.context, cache_key)
|
||||||
|
}
|
||||||
|
|
||||||
/// Enumerate pixels in an Image, use `with_image` for better performance
|
/// Enumerate pixels in an Image, use `with_image` for better performance
|
||||||
pub fn with_pixels<F: FnMut(i32, i32, Color)>(
|
pub fn with_pixels<F: FnMut(i32, i32, Color)>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue