From 208d146a034b5b187d7f2a0ac7c3016e10a4f449 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 26 Aug 2023 13:42:20 -0400 Subject: [PATCH] Force fontconfig to look at the correct path for fonts.conf on windows --- common/paths.cpp | 11 +++++++++++ common/pgm_base.cpp | 7 +++++++ include/paths.h | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/common/paths.cpp b/common/paths.cpp index 56d6561fee..e545b32bfd 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -443,6 +443,17 @@ wxString PATHS::GetOSXKicadDataDir() #ifdef __WXWINDOWS__ +wxString PATHS::GetWindowsFontConfigDir() +{ + wxFileName fn; + fn.AssignDir( getWindowsKiCadRoot() ); + fn.AppendDir( wxS( "etc" ) ); + fn.AppendDir( wxS( "fonts" ) ); + + return fn.GetPathWithSep(); +} + + wxString PATHS::getWindowsKiCadRoot() { wxFileName root( Pgm().GetExecutablePath() + wxT( "/../" ) ); diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 30d32f36c5..2cb9e7c098 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -512,6 +512,13 @@ bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit, bool aIsUnitTest ) SetLanguagePath(); SetDefaultLanguage( tmp ); +#ifdef _MSC_VER + // We need to set this because the internal fontconfig logic + // seems to search relative to the dll rather the other logic it + // has to look for the /etc folder above the dll + wxSetEnv( "FONTCONFIG_PATH", PATHS::GetWindowsFontConfigDir() ); +#endif + m_settings_manager = std::make_unique( aHeadless ); m_background_jobs_monitor = std::make_unique(); m_notifications_manager = std::make_unique(); diff --git a/include/paths.h b/include/paths.h index df3cd4e031..7dfa9f5d1d 100644 --- a/include/paths.h +++ b/include/paths.h @@ -170,6 +170,13 @@ public: static wxString GetOSXKicadDataDir(); #endif +#ifdef __WXWINDOWS__ + /** + * @return The macOS specific bundle data directory for KiCad + */ + static wxString GetWindowsFontConfigDir(); +#endif + private: // we are a static helper PATHS() {}