git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit51e06d901fd5979664be36b349bb9d0001ea1bdb
parent1a35536d7b
authorLucas Galante <[email protected]>
date2026-07-07 08:48
refactor: resolve font dir via $CCE_FONTS_DIR / $HOME instead of hardcoded path

load_fonts_dir was hardcoded to /home/lsgalante/Dropbox/Fonts. Resolve it from
$CCE_FONTS_DIR, falling back to $HOME/Dropbox/Fonts — same location by default,
but no hardcoded username and overridable.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

 src/lib.rs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lib.rs b/src/lib.rs
index e7344e9..9eea1e6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,7 +22,13 @@ pub static BAR_THICKNESS: std::sync::atomic::AtomicU32 = std::sync::atomic::Atom
 
 pub fn create_font_system() -> glyphon::FontSystem {
     let mut db = glyphon::cosmic_text::fontdb::Database::new();
-    db.load_fonts_dir("/home/lsgalante/Dropbox/Fonts");
+    // Font directory: $CCE_FONTS_DIR if set, else ~/Dropbox/Fonts. Resolving via
+    // $HOME keeps the existing location while dropping the hardcoded username.
+    let fonts_dir = std::env::var("CCE_FONTS_DIR").unwrap_or_else(|_| {
+        let home = std::env::var("HOME").unwrap_or_default();
+        format!("{home}/Dropbox/Fonts")
+    });
+    db.load_fonts_dir(&fonts_dir);
     if std::env::var("CCE_LOAD_SYSTEM_FONTS").is_ok() {
         db.load_system_fonts();
     }