Skip to main content

euv_core/font/glyph/
impl.rs

1use super::*;
2
3/// Construction helpers for `GlyphKey`.
4impl GlyphKey {
5    /// Builds a quantized `GlyphKey` from a character, pixel size, and font weight.
6    ///
7    /// # Arguments
8    ///
9    /// - `char` - Character to rasterize.
10    /// - `f32` - Effective physical font size in pixels.
11    /// - `FontWeight` - Font weight determining bold synthesis.
12    ///
13    /// # Returns
14    ///
15    /// - `Self` - Quantized cache key.
16    #[must_use]
17    pub fn from_style(codepoint: char, physical_size: f32, weight: FontWeight) -> Self {
18        let clamped: f32 = physical_size.clamp(6.0, 256.0);
19        let size_tenths: u16 = (clamped * 10.0 + 0.5) as u16;
20        Self::new(codepoint, size_tenths, weight.is_bold())
21    }
22}