GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
feat: add create_font_system_with_system_fonts variant
Factor create_font_system into a shared build_font_system(load_system_fonts)
and expose a variant that always loads installed system fonts (additive to the
bundled CCE fonts) for apps that need them — e.g. the font picker.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
src/lib.rs | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/lib.rs b/src/lib.rs
index 7570de0..4ed939d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -38,10 +38,24 @@ pub fn icons_dir() -> String {
})
}
+/// Build a glyphon `FontSystem` loaded with the bundled CCE fonts (house style).
+/// System fonts are loaded only if `$CCE_LOAD_SYSTEM_FONTS` is set. Configured
+/// custom fonts are validated with a warning if missing.
pub fn create_font_system() -> glyphon::FontSystem {
+ build_font_system(false)
+}
+
+/// Like [`create_font_system`] but always also loads installed system fonts, for
+/// apps that must see every font on the system (e.g. the font picker) or want
+/// them as fallbacks. Additive — bundled CCE fonts are still loaded.
+pub fn create_font_system_with_system_fonts() -> glyphon::FontSystem {
+ build_font_system(true)
+}
+
+fn build_font_system(load_system_fonts: bool) -> glyphon::FontSystem {
let mut db = glyphon::cosmic_text::fontdb::Database::new();
db.load_fonts_dir(fonts_dir());
- if std::env::var("CCE_LOAD_SYSTEM_FONTS").is_ok() {
+ if load_system_fonts || std::env::var("CCE_LOAD_SYSTEM_FONTS").is_ok() {
db.load_system_fonts();
}