diff options
| author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-03-01 10:55:47 +0200 | 
|---|---|---|
| committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-03-01 10:55:47 +0200 | 
| commit | 5715cda6e061294ae344ff6275ee4c643b91bf0f (patch) | |
| tree | 6d5a14ed98695b6c12602d1b47ac27e7730de13c /indra/llrender | |
| parent | b9793dc6e79597fc2c6f518f3a4dad75b5229beb (diff) | |
| parent | 03db2ddc9c27cf842c6185826617b0da0d2b87f5 (diff) | |
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/llrender')
| -rw-r--r-- | indra/llrender/llfontgl.cpp | 57 | 
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 {};  } | 
