Implement basic text caching in iced_wgpu

This commit is contained in:
Héctor Ramón Jiménez 2023-02-02 01:24:27 +01:00
parent 032e860f13
commit 1d0c44fb25
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 157 additions and 58 deletions

View file

@ -1,3 +1,5 @@
use std::hash::{Hash, Hasher};
/// A font.
#[derive(Debug, Clone, Copy)]
pub enum Font {
@ -22,3 +24,17 @@ impl Default for Font {
Font::Default
}
}
impl Hash for Font {
fn hash<H: Hasher>(&self, hasher: &mut H) {
match self {
Self::Default => {
0.hash(hasher);
}
Self::External { name, .. } => {
1.hash(hasher);
name.hash(hasher);
}
}
}
}