From dab42a1afb881b8e7d0a7b50ae529545b45ecf5b Mon Sep 17 00:00:00 2001 From: saurtron Date: Wed, 11 Dec 2024 14:38:54 +0100 Subject: [PATCH] get proper size for osFontsDir Co-authored-by: sprunk --- rts/Rendering/Fonts/CFontTexture.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rts/Rendering/Fonts/CFontTexture.cpp b/rts/Rendering/Fonts/CFontTexture.cpp index a638eef365..7a66a7a4d8 100644 --- a/rts/Rendering/Fonts/CFontTexture.cpp +++ b/rts/Rendering/Fonts/CFontTexture.cpp @@ -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 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 osFontsDir (neededSize); + ExpandEnvironmentStrings(winFontPath, osFontsDir.data(), osFontsDir.size()); static constexpr const char* configFmt = R"(%sfontcache)"; std::string configFmtVar = fmt::sprintf(configFmt, osFontsDir.data()); #else