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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! Font setup — the OS's default monospace font for all text.
//!
//! This repo ships NO font file. It used to ship one, `BrepIcons.ttf`, a
//! monoline icon face that led egui's fallback chain and supplied every
//! specialized UI glyph. Every one of those glyphs is now drawn from its SVG
//! instead ([`crate::icons`] + [`crate::icon_text`]), which is what a
//! multi-colour icon needs anyway — a TrueType glyph can only be one colour —
//! so the face had nothing left to draw and went. An icon character is now only
//! ever a KEY into the icon catalog, never something a font renders.
//!
//! The BINARY still carries four faces, and that is not ours to drop: eframe's
//! `default_fonts` feature is enabled unconditionally in Cargo.toml and pulls
//! `epaint_default_fonts`, whose whole contents are four `include_bytes!`
//! constants — Ubuntu-Light, NotoEmoji-Regular, Hack-Regular and
//! emoji-icon-font. `include_bytes!` runs at compile time, so those four are
//! linked into every native binary and wasm module whether or not the fallback
//! below ever draws with them. That is a licence obligation, not a detail: two
//! of them are conjoined OFL-1.1 / Ubuntu-font-1.0, so a binary release must
//! carry their notices. See THIRD-PARTY-NOTICES.md.
//!
//! The TEXT a user reads comes from none of the four on native — it is the
//! operating system's default monospace font, located and read at runtime via
//! fontconfig, so the UI reads with the user's own system monospace.
//!
//! Platform reality: only native can read OS font files. On wasm (browser) —
//! and on native if the OS monospace can't be located — we fall back to egui's
//! bundled default fonts (eframe feature `default_fonts`) for text + emoji.
//!
//! Installed at app creation from each shell entry point (`lib.rs` wasm `start`,
//! `main.rs` native `run_native`).
use egui;
/// Install fonts into `ctx`. Call once, at app creation.
/// A minimal `FontDefinitions` whose ONLY text font is the OS monospace — no
/// bundled fallbacks.
/// Locate and read the OS default monospace font (path + collection index).
/// Native only, via fontconfig's `fc-match`; returns `None` on any failure so
/// the caller falls back to egui's bundled defaults.
/// wasm has no OS font access — always fall back to egui's bundled defaults.