pub struct GlyphCacheKey {Show 14 fields
pub font_id: u64,
pub font_index: u32,
pub glyph_id: u32,
pub size_bits: u32,
pub hinted: bool,
pub subpixel_x: u8,
pub context_color: AlphaColor<Srgb>,
pub context_color_packed: u32,
pub embolden_x_bits: u32,
pub embolden_y_bits: u32,
pub embolden_join_bits: u8,
pub embolden_miter_limit_bits: u32,
pub embolden_tolerance_bits: u32,
pub var_coords: SmallVec<[NormalizedCoord; 4]>,
}Expand description
Unique identifier for a cached glyph bitmap.
Two glyphs with the same key are visually identical and can share the same cached bitmap. The key includes all parameters that affect the glyph’s appearance.
var_coords is deliberately excluded from Hash/Eq because the
GlyphAtlas uses a two-level map
structure that already partitions entries by variation coordinates.
Callers that use a flat map must ensure equivalent var_coords
externally.
Fields§
§font_id: u64Unique identifier for the font blob.
font_index: u32Index within font collection (for TTC files).
glyph_id: u32Glyph index within the font.
size_bits: u32Font size as f32 bits (exact match, no quantization).
hinted: boolWhether hinting was applied.
subpixel_x: u8Horizontal subpixel position (0 to SUBPIXEL_BUCKETS-1 for outlines),
or a sentinel (SUBPIXEL_COLR / SUBPIXEL_BITMAP) for non-outline glyphs.
context_color: AlphaColor<Srgb>Context color for COLR glyphs. Only used for rendering, not for Hash/Eq.
context_color_packed: u32Pre-packed context color (premultiplied RGBA8 as u32) used in Hash/Eq.
embolden_x_bits: u32Synthetic embolden amount. Only non-zero for outline glyphs.
embolden_y_bits: u32Synthetic embolden amount. Only non-zero for outline glyphs.
embolden_join_bits: u8Join style for synthetic embolden. Only meaningful for outline glyphs.
embolden_miter_limit_bits: u32Miter limit for synthetic embolden. Only meaningful for outline glyphs.
embolden_tolerance_bits: u32Tolerance for synthetic embolden. Only meaningful for outline glyphs.
var_coords: SmallVec<[NormalizedCoord; 4]>Variation coordinates for variable fonts.
Implementations§
Source§impl GlyphCacheKey
impl GlyphCacheKey
Sourcepub fn new(
font_id: u64,
font_index: u32,
glyph_id: u32,
size: f32,
hinted: bool,
fractional_x: f32,
context_color: AlphaColor<Srgb>,
context_color_packed: u32,
embolden: FontEmbolden,
var_coords: &[NormalizedCoord],
) -> Self
pub fn new( font_id: u64, font_index: u32, glyph_id: u32, size: f32, hinted: bool, fractional_x: f32, context_color: AlphaColor<Srgb>, context_color_packed: u32, embolden: FontEmbolden, var_coords: &[NormalizedCoord], ) -> Self
Creates a new cache key.
fractional_x (the fractional pixel offset) is quantized into
SUBPIXEL_BUCKETS buckets, so nearby positions share the same entry.
Trait Implementations§
Source§impl Clone for GlyphCacheKey
impl Clone for GlyphCacheKey
Source§fn clone(&self) -> GlyphCacheKey
fn clone(&self) -> GlyphCacheKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GlyphCacheKey
impl Debug for GlyphCacheKey
Source§impl Hash for GlyphCacheKey
Manual Hash and PartialEq use the pre-packed context_color_packed field
(a premultiplied RGBA8 u32) instead of AlphaColor<Srgb>, which doesn’t
implement Hash/Eq. Packing once at construction avoids repeated work
during lookups. glyph_id is compared first for early short-circuit.
impl Hash for GlyphCacheKey
Manual Hash and PartialEq use the pre-packed context_color_packed field
(a premultiplied RGBA8 u32) instead of AlphaColor<Srgb>, which doesn’t
implement Hash/Eq. Packing once at construction avoids repeated work
during lookups. glyph_id is compared first for early short-circuit.