Skip to content

Commit

Permalink
get proper size for osFontsDir
Browse files Browse the repository at this point in the history
Co-authored-by: sprunk <[email protected]>
  • Loading branch information
saurtron and sprunk authored Dec 11, 2024
1 parent 23b27ff commit dab42a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rts/Rendering/Fonts/CFontTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ class FtLibraryHandler {
// and system fonts included. also linux actually has system config files that can be used by fontconfig.

#ifdef _WIN32
std::array<char, 4096> osFontsDir;
ExpandEnvironmentStrings("%WINDIR%\\fonts", osFontsDir.data(), osFontsDir.size()); // expands %HOME% etc.
static constexpr auto winFontPath = "%WINDIR%\\fonts";
const int neededSize = ExpandEnvironmentStrings(winFontPath, nullptr, 0);
std::vector <char> osFontsDir (neededSize);
ExpandEnvironmentStrings(winFontPath, osFontsDir.data(), osFontsDir.size());
static constexpr const char* configFmt = R"(<fontconfig><dir>%s</dir><cachedir>fontcache</cachedir></fontconfig>)";
std::string configFmtVar = fmt::sprintf(configFmt, osFontsDir.data());
#else
Expand Down

0 comments on commit dab42a1

Please sign in to comment.