Skip to content

Commit

Permalink
Custom xml for windows since mingw doesn't work with the fontconfig
Browse files Browse the repository at this point in the history
special strings.
  • Loading branch information
saurtron committed Dec 11, 2024
1 parent f83afe1 commit 4cd96ed
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rts/Rendering/Fonts/CFontTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@ class FtLibraryHandler {

#ifdef _WIN32
// fontconfig will resolve the special keys here.
static constexpr const char* configFmt = R"(<fontconfig><dir>WINDOWSFONTDIR</dir><cachedir>fontcache</cachedir><cachedir>LOCAL_APPDATA_FONTCONFIG_CACHE</cachedir></fontconfig>)";
std::array<char, 4096> osFontsDir;
ExpandEnvironmentStrings("%WINDIR%\\fonts", osFontsDir.data(), osFontsDir.size()); // expands %HOME% etc.
static constexpr const char* configFmt = R"(<fontconfig><dir>%s</dir><cachedir>fontcache</cachedir></fontconfig>)";
std::string configFmtVar = fmt::sprintf(configFmt, osFontsDir.data());
#else
static constexpr const char* configFmt = R"(<fontconfig><cachedir>fontcache</cachedir></fontconfig>)";
#endif

#ifdef _WIN32
// Explicitly set the config with xml for windows.
res = FcConfigParseAndLoadFromMemory(config, reinterpret_cast<const FcChar8*>(configFmt), FcTrue);
res = FcConfigParseAndLoadFromMemory(config, reinterpret_cast<const FcChar8*>(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);
Expand Down

0 comments on commit 4cd96ed

Please sign in to comment.