euv_core/font/glyph/struct.rs
1use super::*;
2
3/// Cache key uniquely identifying a rasterized glyph bitmap.
4#[derive(Clone, Copy, Debug, Default, Eq, Getter, New)]
5pub struct GlyphKey {
6 /// Unicode scalar value of the character.
7 #[get(type(copy))]
8 pub(crate) codepoint: char,
9 /// Quantized pixel height in tenths of a pixel.
10 #[get(type(copy))]
11 pub(crate) size_tenths: u16,
12 /// Whether bold stroke thickening is active.
13 #[get(type(copy))]
14 pub(crate) bold: bool,
15 /// Whether a fixed-pitch monospace typeface is requested.
16 #[new(skip)]
17 #[get(type(copy))]
18 pub(crate) monospace: bool,
19 /// Whether an italic typeface is requested.
20 #[new(skip)]
21 #[get(type(copy))]
22 pub(crate) italic: bool,
23}
24
25/// Rasterized alpha-coverage glyph bitmap ready for software blitting or GPU atlas upload.
26#[derive(Clone, Debug, Default, Eq, Getter, New, PartialEq)]
27pub struct RasterizedGlyph {
28 /// Bitmap width in physical pixels.
29 #[get(type(copy))]
30 pub(crate) width: u32,
31 /// Bitmap height in physical pixels.
32 #[get(type(copy))]
33 pub(crate) height: u32,
34 /// Horizontal advance in physical pixels.
35 #[get(type(copy))]
36 pub(crate) advance: u32,
37 /// Alpha coverage values in row-major order (`0..=255`).
38 pub(crate) coverage: Vec<u8>,
39}
40
41/// Resolution-independent Euclidean signed-distance field for crisp gigantic-scale glyph reconstruction (`> 512px`).
42#[derive(Clone, Debug, Default, Getter, New, PartialEq)]
43pub struct SdfGlyphField {
44 /// Field width in canonical texels (including SDF spread padding).
45 #[get(type(copy))]
46 pub(crate) width: u32,
47 /// Field height in canonical texels (including SDF spread padding).
48 #[get(type(copy))]
49 pub(crate) height: u32,
50 /// Canonical glyph raster size in pixels from which the SDF was extracted.
51 #[get(type(copy))]
52 pub(crate) canonical_size_px: f32,
53 /// Signed-distance spread radius in canonical pixels.
54 #[get(type(copy))]
55 pub(crate) spread_px: f32,
56 /// Horizontal advance ratio (`canonical_advance / canonical_size_px`).
57 #[get(type(copy))]
58 pub(crate) advance_ratio: f32,
59 /// Signed Euclidean distances in canonical pixel units (negative inside glyph, positive outside).
60 pub(crate) distances: Vec<f32>,
61}