iced-yoda/core/src/font.rs

41 lines
818 B
Rust
Raw Normal View History

use std::hash::{Hash, Hasher};
2019-11-18 07:16:19 +01:00
/// A font.
#[derive(Debug, Clone, Copy)]
pub enum Font {
2019-11-18 07:16:19 +01:00
/// The default font.
///
/// This is normally a font configured in a renderer or loaded from the
/// system.
Default,
2019-11-18 07:16:19 +01:00
/// An external font.
External {
2019-11-18 07:16:19 +01:00
/// The name of the external font
name: &'static str,
2019-11-18 07:16:19 +01:00
/// The bytes of the external font
bytes: &'static [u8],
},
}
2020-04-23 22:17:00 +02:00
impl Default for Font {
fn default() -> 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);
}
}
}
}