1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2023-present, Raphael Amorim.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//! Shared atlas types used by both the Metal and wgpu grid backends.
//!
//! The atlas texture itself is backend-specific (Metal `Texture` vs
//! wgpu `Texture`), so each backend owns its own atlas struct. These
//! types are the common vocabulary: how callers identify a glyph
//! (`GlyphKey`), where it landed in the atlas (`AtlasSlot`), and the
//! caller-supplied rasterized pixels (`RasterizedGlyph`).
/// Identifier for a rasterized glyph. `(font_id, glyph_id)` is
/// enough when a grid renders at one font size; `size_bucket` lets
/// us share the atlas across minor size changes (e.g. during a
/// resize animation) without re-rasterizing. Quantize to 1/4 of a
/// physical pixel to keep the cache hit rate high:
/// `size_bucket = (scaled_px * 4.0).round() as u16`.
/// Atlas position + glyph metrics for one rasterized glyph. Exactly
/// the fields the `grid_text_vertex` shader reads via `CellText`:
/// `glyph_pos`, `glyph_size`, `bearings`.
/// Raw rasterized glyph bitmap, caller-supplied. The atlas doesn't
/// rasterize itself — that stays in whatever shaping / scaling path
/// the caller uses (sugarloaf's swash-backed `ScaleContext`).