Skip to main content

GlyphCacheKey

Struct GlyphCacheKey 

Source
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: u64

Unique identifier for the font blob.

§font_index: u32

Index within font collection (for TTC files).

§glyph_id: u32

Glyph index within the font.

§size_bits: u32

Font size as f32 bits (exact match, no quantization).

§hinted: bool

Whether hinting was applied.

§subpixel_x: u8

Horizontal 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: u32

Pre-packed context color (premultiplied RGBA8 as u32) used in Hash/Eq.

§embolden_x_bits: u32

Synthetic embolden amount. Only non-zero for outline glyphs.

§embolden_y_bits: u32

Synthetic embolden amount. Only non-zero for outline glyphs.

§embolden_join_bits: u8

Join style for synthetic embolden. Only meaningful for outline glyphs.

§embolden_miter_limit_bits: u32

Miter limit for synthetic embolden. Only meaningful for outline glyphs.

§embolden_tolerance_bits: u32

Tolerance for synthetic embolden. Only meaningful for outline glyphs.

§var_coords: SmallVec<[NormalizedCoord; 4]>

Variation coordinates for variable fonts.

Implementations§

Source§

impl GlyphCacheKey

Source

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

Source§

fn clone(&self) -> GlyphCacheKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GlyphCacheKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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.

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for GlyphCacheKey

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for GlyphCacheKey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.