From 4cd96edd9ca2da49f6267722cf6ef0c8331aefcf Mon Sep 17 00:00:00 2001 From: Saurtron Date: Wed, 11 Dec 2024 02:36:46 +0100 Subject: [PATCH] Custom xml for windows since mingw doesn't work with the fontconfig special strings. --- rts/Rendering/Fonts/CFontTexture.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rts/Rendering/Fonts/CFontTexture.cpp b/rts/Rendering/Fonts/CFontTexture.cpp index b969389c18..53b0aec9c4 100644 --- a/rts/Rendering/Fonts/CFontTexture.cpp +++ b/rts/Rendering/Fonts/CFontTexture.cpp @@ -151,14 +151,17 @@ class FtLibraryHandler { #ifdef _WIN32 // fontconfig will resolve the special keys here. - static constexpr const char* configFmt = R"(WINDOWSFONTDIRfontcacheLOCAL_APPDATA_FONTCONFIG_CACHE)"; + std::array osFontsDir; + ExpandEnvironmentStrings("%WINDIR%\\fonts", osFontsDir.data(), osFontsDir.size()); // expands %HOME% etc. + static constexpr const char* configFmt = R"(%sfontcache)"; + std::string configFmtVar = fmt::sprintf(configFmt, osFontsDir.data()); #else static constexpr const char* configFmt = R"(fontcache)"; #endif #ifdef _WIN32 // Explicitly set the config with xml for windows. - res = FcConfigParseAndLoadFromMemory(config, reinterpret_cast(configFmt), FcTrue); + res = FcConfigParseAndLoadFromMemory(config, reinterpret_cast(configFmtVar.c_str()), FcTrue); #else // Load system configuration (passing 0 here so fc will use the default os config file if possible). res = FcConfigParseAndLoad(config, 0, true);