Skip to main content

aetna_fonts/
lib.rs

1//! Bundled font assets for Aetna.
2//!
3//! This crate is a thin re-exporter: each Cargo feature pulls in a
4//! sibling crate that bundles the matching font family
5//! (`aetna-fonts-inter`, `aetna-fonts-jetbrains-mono`, `aetna-fonts-roboto`,
6//! `aetna-fonts-emoji`, `aetna-fonts-symbols`).
7//! Splitting the families across crates keeps every published
8//! `.crate` artifact under crates.io's per-crate upload size limit,
9//! while the `aetna-fonts` API stays the same surface aetna-core (and
10//! application code) consumes.
11//!
12//! The default feature set is generous (Inter + JetBrains Mono + emoji +
13//! symbols) — chosen so that LLM output, which freely reaches for arrows,
14//! math operators, dingbats, and box-drawing characters, doesn't render as
15//! tofu (`◻`) out of the box, and so code samples land on a real
16//! programmer's mono instead of the UI sans.
17//!
18//! # Feature flags
19//!
20//! | feature          | adds                                                  | size (raw)   |
21//! |------------------|-------------------------------------------------------|--------------|
22//! | `inter`          | Inter Variable Roman / Italic                         | ~1.8 MB      |
23//! | `jetbrains-mono` | JetBrains Mono Variable Roman / Italic (with ligatures) | ~600 KB    |
24//! | `roboto`         | Roboto Regular / Medium / Bold / Italic               | ~1.8 MB      |
25//! | `emoji`          | NotoColorEmoji (CBDT color bitmaps)                   | ~10 MB       |
26//! | `symbols`        | NotoSansSymbols2 + NotoSansMath                       | ~2.2 MB      |
27//!
28//! `default = ["default_fonts"]` and `default_fonts = ["inter",
29//! "jetbrains-mono", "emoji", "symbols"]`. Roboto was previously bundled
30//! by default; it is still available behind the `roboto` feature for
31//! consumers that want the Material UI sans. To skip the bundled fonts
32//! entirely (for example, to ship your own Material Symbols or a brand
33//! typeface):
34//!
35//! ```toml
36//! aetna-fonts = { version = "0.3", default-features = false }
37//! ```
38//!
39//! CJK was previously available as an opt-in `cjk` feature shipping
40//! NotoSansCJK SC (~16 MB). The bundled font pushed the published
41//! `.crate` over crates.io's upload cap, so it has been removed for
42//! this release; a bring-your-own-font path will return in a later
43//! release. In the meantime, register a CJK face into aetna-core's
44//! `fontdb` directly via the public text-atlas APIs.
45//!
46//! Color emoji (NotoColorEmoji) is rendered through aetna-core's
47//! unified RGBA atlas — outline glyphs are stored as
48//! `(255, 255, 255, alpha)` and color emoji as native RGBA, so backends
49//! sample one texture format and run one shader path.
50//!
51//! # API
52//!
53//! Each enabled font family re-exports a `pub static FOO: &[u8]`
54//! constant from its sibling crate. The [`DEFAULT_FONTS`] slice
55//! collects every byte slice that is enabled in the current build,
56//! in priority order (sans-serif text first, then symbol / emoji
57//! fallbacks). aetna-core's atlas loads them all into its `fontdb`
58//! so cosmic-text's per-codepoint fallback can pick from them.
59
60#![no_std]
61
62#[cfg(feature = "roboto")]
63pub use aetna_fonts_roboto::{ROBOTO_BOLD, ROBOTO_ITALIC, ROBOTO_MEDIUM, ROBOTO_REGULAR};
64
65#[cfg(feature = "inter")]
66pub use aetna_fonts_inter::{INTER_VARIABLE, INTER_VARIABLE_ITALIC};
67
68#[cfg(feature = "jetbrains-mono")]
69pub use aetna_fonts_jetbrains_mono::{JETBRAINS_MONO_VARIABLE, JETBRAINS_MONO_VARIABLE_ITALIC};
70
71#[cfg(feature = "emoji")]
72pub use aetna_fonts_emoji::NOTO_COLOR_EMOJI;
73
74#[cfg(feature = "symbols")]
75pub use aetna_fonts_symbols::{NOTO_SANS_MATH_REGULAR, NOTO_SANS_SYMBOLS2_REGULAR};
76
77/// Byte slices for every font enabled in the current build, in priority
78/// order: text faces first, then symbol / emoji fallbacks.
79///
80/// aetna-core loads every entry into its `fontdb`. cosmic-text's font
81/// matcher then walks the database per codepoint when a primary face
82/// lacks a glyph — the order here only documents intent; cosmic-text's
83/// fallback is keyed on Unicode coverage, not list position.
84pub const DEFAULT_FONTS: &[&[u8]] = &[
85    #[cfg(feature = "inter")]
86    INTER_VARIABLE,
87    #[cfg(feature = "inter")]
88    INTER_VARIABLE_ITALIC,
89    #[cfg(feature = "jetbrains-mono")]
90    JETBRAINS_MONO_VARIABLE,
91    #[cfg(feature = "jetbrains-mono")]
92    JETBRAINS_MONO_VARIABLE_ITALIC,
93    #[cfg(feature = "roboto")]
94    ROBOTO_REGULAR,
95    #[cfg(feature = "roboto")]
96    ROBOTO_MEDIUM,
97    #[cfg(feature = "roboto")]
98    ROBOTO_BOLD,
99    #[cfg(feature = "roboto")]
100    ROBOTO_ITALIC,
101    #[cfg(feature = "emoji")]
102    NOTO_COLOR_EMOJI,
103    #[cfg(feature = "symbols")]
104    NOTO_SANS_SYMBOLS2_REGULAR,
105    #[cfg(feature = "symbols")]
106    NOTO_SANS_MATH_REGULAR,
107];