diff options
| author | 2023-02-04 07:33:33 +0100 | |
|---|---|---|
| committer | 2023-02-24 13:28:24 +0100 | |
| commit | b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb (patch) | |
| tree | e100af1dd98d23b29046bc951b04b440d2aa5bc2 /core | |
| parent | a7580e0696a1a0ba76a89db3f78bc99ba3fbb361 (diff) | |
| download | iced-b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb.tar.gz iced-b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb.tar.bz2 iced-b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb.zip  | |
Overhaul `Font` type to allow font family selection
Diffstat (limited to '')
| -rw-r--r-- | core/src/font.rs | 53 | 
1 files changed, 21 insertions, 32 deletions
diff --git a/core/src/font.rs b/core/src/font.rs index 130e378e..1f774a70 100644 --- a/core/src/font.rs +++ b/core/src/font.rs @@ -1,40 +1,29 @@ -use std::hash::{Hash, Hasher}; +use std::hash::Hash;  /// A font. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]  pub enum Font { -    /// The default font. -    /// -    /// This is normally a font configured in a renderer or loaded from the -    /// system. -    Default, +    /// The name of a font family of choice. +    Name(&'static str), -    /// An external font. -    External { -        /// The name of the external font -        name: &'static str, +    /// Serif fonts represent the formal text style for a script. +    Serif, -        /// The bytes of the external font -        bytes: &'static [u8], -    }, -} +    /// Glyphs in sans-serif fonts, as the term is used in CSS, are generally low +    /// contrast and have stroke endings that are plain — without any flaring, +    /// cross stroke, or other ornamentation. +    SansSerif, -impl Default for Font { -    fn default() -> Font { -        Font::Default -    } -} +    /// Glyphs in cursive fonts generally use a more informal script style, and +    /// the result looks more like handwritten pen or brush writing than printed +    /// letterwork. +    Cursive, + +    /// Fantasy fonts are primarily decorative or expressive fonts that contain +    /// decorative or expressive representations of characters. +    Fantasy, -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); -            } -        } -    } +    /// The sole criterion of a monospace font is that all glyphs have the same +    /// fixed width. +    Monospace,  }  | 
