Skip to content

Commit

Permalink
Set fontconfig environment in Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulat committed Oct 10, 2023
1 parent 4916dfe commit 3a754c0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scwx-qt/source/scwx/qt/manager/font_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <scwx/qt/manager/font_manager.hpp>
#include <scwx/qt/manager/settings_manager.hpp>
#include <scwx/qt/settings/text_settings.hpp>
#include <scwx/util/environment.hpp>
#include <scwx/util/logger.hpp>

#include <filesystem>
Expand Down Expand Up @@ -50,6 +51,7 @@ class FontManager::Impl
public:
explicit Impl(FontManager* self) : self_ {self}
{
InitializeEnvironment();
InitializeFontCache();
InitializeFontconfig();
ConnectSignals();
Expand All @@ -58,6 +60,7 @@ class FontManager::Impl

void ConnectSignals();
void FinalizeFontconfig();
void InitializeEnvironment();
void InitializeFontCache();
void InitializeFontconfig();
void UpdateImGuiFont(types::FontCategory fontCategory);
Expand Down Expand Up @@ -385,6 +388,21 @@ void FontManager::LoadApplicationFont(types::Font font,
}
}

void FontManager::Impl::InitializeEnvironment()
{
#if defined(__linux__)
// Because of the way Fontconfig is built with Conan, FONTCONFIG_PATH must be
// defined on Linux to ensure fonts can be found
static const std::string kFontconfigPathKey {"FONTCONFIG_PATH"};

std::string fontconfigPath = scwx::util::GetEnvironment(kFontconfigPathKey);
if (fontconfigPath.empty())
{
scwx::util::SetEnvironment(kFontconfigPathKey, "/etc/fonts");
}
#endif
}

void FontManager::Impl::InitializeFontCache()
{
std::string cachePath {
Expand Down

0 comments on commit 3a754c0

Please sign in to comment.