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
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2026 FernTech
//! Runtime loader for the platform's installed color-emoji font.
//!
//! Enabled by the `system-emoji` Cargo feature. Unlike the embedded
//! `fonts-*` fallbacks in [`typesetter_bridge`](crate::typesetter_bridge),
//! this module does not ship any font data: color-emoji fonts are
//! typically 20-30 MB (Linux/Windows) or ~180 MB (macOS) and would
//! bloat the binary. Instead, at startup we probe a short per-OS list
//! of well-known filesystem paths and `mmap` the first one found.
//! Silent on miss — the caller sees `None` and the shaper's `.notdef`
//! fallback loop simply has no emoji font to consult.
//!
//! ## Why mmap instead of `fs::read`
//!
//! Apple Color Emoji.ttc is ~183 MB. With `fs::read` the kernel reads
//! the whole file into an owned `Vec<u8>` on the heap — that's 183 MB
//! of anonymous memory that lives for the process lifetime, even
//! though shaping touches only a fraction of the glyph tables.
//! `memmap2::Mmap` maps the file pages into the address space; the
//! kernel pages them in on demand and can reclaim them under memory
//! pressure. text-typeset's `register_font_shared` accepts an
//! `Arc<Mmap>` directly, so the bytes are never copied to the heap.
use Arc;
use SharedFontData;
const CANDIDATES: & = &;
const CANDIDATES: & = &;
const CANDIDATES: & = &;
const CANDIDATES: & = &;
/// Map the first emoji font found at a well-known system path into
/// the process address space, returning a shared handle suitable for
/// [`text_typeset::TextFontService::register_font_shared`]. Returns
/// `None` if no candidate exists.
pub