zenthra_text/types/glyph.rs
1use cosmic_text::CacheKey;
2
3/// Unique identifier for a glyph at a specific size and style.
4/// Directly maps to `cosmic_text::CacheKey`.
5pub type GlyphKey = CacheKey;
6
7/// Metadata for a glyph stored in the GPU atlas.
8#[derive(Debug, Clone, Copy, PartialEq)]
9pub struct AtlasEntry {
10 /// Normalized UV coordinates (top-left) in the atlas texture.
11 pub uv_pos: [f32; 2],
12 /// Normalized UV size (width, height) in the atlas texture.
13 pub uv_size: [f32; 2],
14 /// Physical pixel size [width, height] of the glyph in the atlas.
15 pub pixel_size: [f32; 2],
16 /// Physical pixel offset [left, top] relative to the logical origin.
17 pub pixel_offset: [f32; 2],
18 /// Whether this is a color glyph.
19 pub is_color: bool,
20}
21
22
23
24/// Raw pixel data and metrics for a rasterized glyph.
25pub struct RasterizedGlyph {
26 /// Width of the rasterized bitmap.
27 pub width: u32,
28 /// Height of the rasterized bitmap.
29 pub height: u32,
30 /// Left offset (displacement from origin).
31 pub left: i32,
32 /// Top offset (displacement from origin).
33 pub top: i32,
34 /// Grayscale or RGBA pixel data.
35 pub data: Vec<u8>,
36 /// Whether this is a color glyph.
37 pub is_color: bool,
38}
39
40
41pub use zenthra_core::GlyphInstance;