From d7f94c5d2a36b413be843197a92b70291a2b3a0d Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 28 May 2024 19:24:41 -0400 Subject: [PATCH] add linux home env var to font path --- src/app/core/controller.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app/core/controller.cc b/src/app/core/controller.cc index 0c28860c..de72b8f1 100644 --- a/src/app/core/controller.cc +++ b/src/app/core/controller.cc @@ -390,17 +390,31 @@ absl::Status Controller::LoadFontFamilies() const { float font_size = (font_path == DROID_SANS) ? FONT_SIZE_DROID_SANS : FONT_SIZE_DEFAULT; +#ifdef __linux__ + std::string const HOME = std::getenv("HOME") ? std::getenv("HOME") : "."; + font_path = HOME + "/" + font_path; +#endif + if (!io.Fonts->AddFontFromFileTTF(font_path, font_size)) { return absl::InternalError( absl::StrFormat("Failed to load font from %s", font_path)); } // Merge icon set - io.Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_MD, ICON_FONT_SIZE, - &icons_config, icons_ranges); + const char *icon_font_path = FONT_ICON_FILE_NAME_MD; +#ifdef __linux__ + icon_font_path = HOME + "/" + icon_font_path; +#endif + io.Fonts->AddFontFromFileTTF(icon_font_path, ICON_FONT_SIZE, &icons_config, + icons_ranges); // Merge Japanese font - io.Fonts->AddFontFromFileTTF(NOTO_SANS_JP, 18.0f, &japanese_font_config, + const char *japanese_font_path = NOTO_SANS_JP; +#ifdef __linux__ + japanese_font_path = HOME + "/" + japanese_font_path; +#endif + io.Fonts->AddFontFromFileTTF(japanese_font_path, 18.0f, + &japanese_font_config, io.Fonts->GetGlyphRangesJapanese()); }