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
53
54
55
//! Font handle for cache keying.
//!
//! `FontHandle` uniquely identifies a font instance by combining a stable
//! `face_id` (hash of the platform face's PostScript name) with size and scale.
//! Platform face pointers are NOT used: CoreText returns fresh `CTFont`
//! addresses for substitute faces across shape calls (notably after IME
//! input-source switches), so pointer-as-identity causes glyph-cache thrash.
/// Unique identifier for a font instance, used as cache key.
///
/// # Cache Key Uniqueness
///
/// `face_id` is a 64-bit FxHash of the face's PostScript name (UTF-8 bytes).
/// Uniqueness comes from the `(face_id, size_lpx_bits, scale_bits)` triple.
/// Two fonts at different sizes from the same face will have distinct handles
/// even though they share `face_id`.
///
/// Two distinct platform face objects (e.g. substitute `CTFont` instances with
/// fresh pointer addresses) that represent the same logical face (same PSName)
/// produce equal `FontHandle`s — by design.