summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2019-02-28 16:37:47 -0800
committerRider Linden <rider@lindenlab.com>2019-02-28 16:37:47 -0800
commite1a76999c3e8aad337d765fcd6eb50c8191409ea (patch)
treebc671ff3f6da473df49f2b834e94ee6150157256 /indra/llrender
parentd7ad30a2d4dfd83f93b0150464214f2df776eb9c (diff)
parent03db2ddc9c27cf842c6185826617b0da0d2b87f5 (diff)
Merge
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llfontgl.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index cf0a117567..8cd18c5fa1 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -40,10 +40,17 @@
#include "v4color.h"
#include "lltexture.h"
#include "lldir.h"
+#include "llstring.h"
// Third party library includes
#include <boost/tokenizer.hpp>
+#if LL_WINDOWS
+#include <Shlobj.h>
+#include <Knownfolders.h>
+#include <Objbase.h>
+#endif // LL_WINDOWS
+
const S32 BOLD_OFFSET = 1;
// static class members
@@ -1063,33 +1070,33 @@ LLFontGL* LLFontGL::getFontDefault()
// static
std::string LLFontGL::getFontPathSystem()
{
- std::string system_path;
-
- // Try to figure out where the system's font files are stored.
- char *system_root = NULL;
-#if LL_WINDOWS
- system_root = getenv("SystemRoot"); /* Flawfinder: ignore */
- if (!system_root)
- {
- LL_WARNS() << "SystemRoot not found, attempting to load fonts from default path." << LL_ENDL;
- }
+#if LL_DARWIN
+ // HACK for Mac OS X
+ return "/System/Library/Fonts/";
+
+#elif LL_WINDOWS
+ auto system_root = LLStringUtil::getenv("SystemRoot");
+ if (! system_root.empty())
+ {
+ std::string fontpath(gDirUtilp->add(system_root, "fonts") + gDirUtilp->getDirDelimiter());
+ LL_INFOS() << "from SystemRoot: " << fontpath << LL_ENDL;
+ return fontpath;
+ }
+
+ wchar_t *pwstr = NULL;
+ HRESULT okay = SHGetKnownFolderPath(FOLDERID_Fonts, 0, NULL, &pwstr);
+ if (SUCCEEDED(okay) && pwstr)
+ {
+ std::string fontpath(ll_convert_wide_to_string(pwstr));
+ // SHGetKnownFolderPath() contract requires us to free pwstr
+ CoTaskMemFree(pwstr);
+ LL_INFOS() << "from SHGetKnownFolderPath(): " << fontpath << LL_ENDL;
+ return fontpath;
+ }
#endif
- if (system_root)
- {
- system_path = llformat("%s/fonts/", system_root);
- }
- else
- {
-#if LL_WINDOWS
- // HACK for windows 98/Me
- system_path = "/WINDOWS/FONTS/";
-#elif LL_DARWIN
- // HACK for Mac OS X
- system_path = "/System/Library/Fonts/";
-#endif
- }
- return system_path;
+ LL_WARNS() << "Could not determine system fonts path" << LL_ENDL;
+ return {};
}