Use ouroboros in FontSystem to avoid lifetime bound
Perhaps not quite what ouroboros is expected to be used for, but it's not too bad, and avoiding the lifetime bound can be a huge help.
This commit is contained in:
parent
ac354c3a2a
commit
0d3fb1dd9d
8 changed files with 85 additions and 62 deletions
|
|
@ -9,7 +9,7 @@ use crate::{CacheKey, Color, FontSystem};
|
|||
|
||||
pub use swash::scale::image::{Content as SwashContent, Image as SwashImage};
|
||||
|
||||
fn swash_image<'a>(font_system: &'a FontSystem<'a>, context: &mut ScaleContext, cache_key: CacheKey) -> Option<SwashImage> {
|
||||
fn swash_image<'a>(font_system: &'a FontSystem, context: &mut ScaleContext, cache_key: CacheKey) -> Option<SwashImage> {
|
||||
let font = match font_system.get_font(cache_key.font_id) {
|
||||
Some(some) => some,
|
||||
None => {
|
||||
|
|
@ -49,14 +49,14 @@ fn swash_image<'a>(font_system: &'a FontSystem<'a>, context: &mut ScaleContext,
|
|||
|
||||
/// Cache for rasterizing with the swash scaler
|
||||
pub struct SwashCache<'a> {
|
||||
font_system: &'a FontSystem<'a>,
|
||||
font_system: &'a FontSystem,
|
||||
context: ScaleContext,
|
||||
pub image_cache: HashMap<CacheKey, Option<SwashImage>>,
|
||||
}
|
||||
|
||||
impl<'a> SwashCache<'a> {
|
||||
/// Create a new swash cache
|
||||
pub fn new(font_system: &'a FontSystem<'a>) -> Self {
|
||||
pub fn new(font_system: &'a FontSystem) -> Self {
|
||||
Self {
|
||||
font_system: font_system,
|
||||
context: ScaleContext::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue