summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llwindow.cpp14
-rw-r--r--indra/llwindow/llwindow.h2
-rw-r--r--indra/llwindow/llwindowmacosx.cpp9
-rw-r--r--indra/llwindow/llwindowmacosx.h2
-rw-r--r--indra/llwindow/llwindowsdl.cpp98
-rw-r--r--indra/llwindow/llwindowsdl.h3
-rw-r--r--indra/llwindow/llwindowwin32.cpp8
-rw-r--r--indra/llwindow/llwindowwin32.h2
8 files changed, 134 insertions, 4 deletions
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index c640a83328..fd850fe258 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -287,6 +287,20 @@ void LLWindow::setCallbacks(LLWindowCallbacks *callbacks)
}
}
+// static
+std::string LLWindow::getFontListSans()
+{
+#if LL_WINDOWS
+ return LLWindowWin32::getFontListSans();
+#elif LL_DARWIN
+ return LLWindowMacOSX::getFontListSans();
+#elif LL_SDL
+ return LLWindowSDL::getFontListSans();
+#else
+ return "";
+#endif
+}
+
#define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400)
#define UTF16_IS_LOW_SURROGATE(U) ((U16)((U) - 0xDC00) < 0x0400)
#define UTF16_SURROGATE_PAIR_TO_UTF32(H,L) (((H) << 10) + (L) - (0xD800 << 10) - 0xDC00 + 0x00010000)
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 81adf8b13a..7a7c14fa35 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -234,6 +234,8 @@ public:
virtual void updateLanguageTextInputArea() {}
virtual void interruptLanguageTextInput() {}
+ static std::string getFontListSans();
+
protected:
LLWindow(BOOL fullscreen, U32 flags);
virtual ~LLWindow() {}
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 8483e37cf9..ba92e80402 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -3394,4 +3394,13 @@ void LLWindowMacOSX::interruptLanguageTextInput()
// Well, if Apple's TSM document is correct, we don't.
}
+//static
+std::string LLWindowMacOSX::getFontListSans()
+{
+ // This is a fairly complete Japanese font that ships with Mac OS X.
+ // The first filename is in UTF8, but it shows up in the font menu as "Hiragino Kaku Gothic Pro W3".
+ // The third filename is in UTF8, but it shows up in the font menu as "STHeiti Light"
+ return "\xE3\x83\x92\xE3\x83\xA9\xE3\x82\xAD\xE3\x82\x99\xE3\x83\x8E\xE8\xA7\x92\xE3\x82\xB3\xE3\x82\x99 Pro W3.otf;\xE3\x83\x92\xE3\x83\xA9\xE3\x82\xAD\xE3\x82\x99\xE3\x83\x8E\xE8\xA7\x92\xE3\x82\xB3\xE3\x82\x99 ProN W3.otf;AppleGothic.dfont;AppleGothic.ttf;\xe5\x8d\x8e\xe6\x96\x87\xe7\xbb\x86\xe9\xbb\x91.ttf";
+}
+
#endif // LL_DARWIN
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 3fb4eff728..0534893aa7 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -116,6 +116,8 @@ public:
/*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b);
/*virtual*/ void interruptLanguageTextInput();
+ static std::string getFontListSans();
+
protected:
LLWindowMacOSX(
char *title, char *name, int x, int y, int width, int height, U32 flags,
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index 519e0e8ec8..5ed6094f4a 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -39,6 +39,7 @@
#include "llgl.h"
#include "llstring.h"
#include "lldir.h"
+#include "llfindlocale.h"
#include "llglheaders.h"
@@ -51,6 +52,10 @@ extern "C" {
#include <locale.h>
#endif // LL_GTK
+extern "C" {
+# include "fontconfig/fontconfig.h"
+}
+
#if LL_LINUX || LL_SOLARIS
// not necessarily available on random SDL platforms, so #if LL_LINUX
// for execv(), waitpid(), fork()
@@ -2027,7 +2032,8 @@ void LLWindowSDL::gatherInput()
// the locale to protect it, as exotic/non-C locales
// causes our code lots of general critical weirdness
// and crashness. (SL-35450)
- std::string saved_locale = setlocale(LC_ALL, NULL);
+ static std::string saved_locale;
+ saved_locale = ll_safe_string(setlocale(LC_ALL, NULL));
// Pump until we've nothing left to do or passed 1/15th of a
// second pumping for this frame.
@@ -2748,8 +2754,8 @@ void spawn_web_browser(const char* escaped_url)
# endif // LL_X11
std::string cmd;
- cmd = gDirUtilp->getAppRODataDir().c_str();
- cmd += gDirUtilp->getDirDelimiter().c_str();
+ cmd = gDirUtilp->getAppRODataDir();
+ cmd += gDirUtilp->getDirDelimiter();
cmd += "launch_url.sh";
char* const argv[] = {(char*)cmd.c_str(), (char*)escaped_url, NULL};
@@ -2826,4 +2832,90 @@ void LLWindowSDL::bringToFront()
#endif // LL_X11
}
+//static
+std::string LLWindowSDL::getFontListSans()
+{
+ // Use libfontconfig to find us a nice ordered list of fallback fonts
+ // specific to this system.
+ std::string final_fallback("/usr/share/fonts/truetype/kochi/kochi-gothic.ttf");
+ // Our 'ideal' font properties which define the sorting results.
+ // slant=0 means Roman, index=0 means the first face in a font file
+ // (the one we actually use), weight=80 means medium weight,
+ // spacing=0 means proportional spacing.
+ std::string sort_order("slant=0:index=0:weight=80:spacing=0");
+ // elide_unicode_coverage removes fonts from the list whose unicode
+ // range is covered by fonts earlier in the list. This usually
+ // removes ~90% of the fonts as redundant (which is great because
+ // the font list can be huge), but might unnecessarily reduce the
+ // renderable range if for some reason our FreeType actually fails
+ // to use some of the fonts we want it to.
+ const bool elide_unicode_coverage = true;
+ std::string rtn;
+ FcFontSet *fs = NULL;
+ FcPattern *sortpat = NULL;
+ int font_count = 0;
+
+ llinfos << "Getting system font list from FontConfig..." << llendl;
+
+ // If the user has a system-wide language preference, then favor
+ // fonts from that language group. This doesn't affect the types
+ // of languages that can be displayed, but ensures that their
+ // preferred language is rendered from a single consistent font where
+ // possible.
+ FL_Locale *locale = NULL;
+ FL_Success success = FL_FindLocale(&locale, FL_MESSAGES);
+ if (success != 0)
+ {
+ if (success >= 2 && locale->lang) // confident!
+ {
+ llinfos << "Preferring fonts of language: "
+ << locale->lang
+ << llendl;
+ sort_order = "lang=" + std::string(locale->lang) + ":"
+ + sort_order;
+ }
+ FL_FreeLocale(&locale);
+ }
+
+ if (!FcInit())
+ {
+ llwarns << "FontConfig failed to initialize." << llendl;
+ return final_fallback;
+ }
+
+ sortpat = FcNameParse((FcChar8*) sort_order.c_str());
+ if (sortpat)
+ {
+ // Sort the list of system fonts from most-to-least-desirable.
+ fs = FcFontSort(NULL, sortpat, elide_unicode_coverage,
+ NULL, NULL);
+ FcPatternDestroy(sortpat);
+ }
+
+ if (fs)
+ {
+ // Get the full pathnames to the fonts, where available,
+ // which is what we really want.
+ int i;
+ for (i=0; i<fs->nfont; ++i)
+ {
+ FcChar8 *filename;
+ if (FcResultMatch == FcPatternGetString(fs->fonts[i],
+ FC_FILE, 0,
+ &filename)
+ && filename)
+ {
+ rtn += std::string((const char*)filename)+";";
+ ++font_count;
+ }
+ }
+ FcFontSetDestroy (fs);
+ }
+
+ lldebugs << "Using font list: " << rtn << llendl;
+ llinfos << "Using " << font_count << " system font(s)." << llendl;
+
+ return rtn + final_fallback;
+}
+
#endif // LL_SDL
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index 51d34eb96f..58bb93bbc7 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -120,6 +120,8 @@ public:
/*virtual*/ void *getPlatformWindow();
/*virtual*/ void bringToFront();
+ static std::string getFontListSans();
+
// Not great that these are public, but they have to be accessible
// by non-class code and it's better than making them global.
#if LL_X11
@@ -154,7 +156,6 @@ protected:
BOOL shouldPostQuit() { return mPostQuit; }
-
protected:
//
// Platform specific methods
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index bbc452fe5e..0a40fb8a95 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -3606,5 +3606,13 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
return FALSE;
}
+//static
+std::string LLWindowWin32::getFontListSans()
+{
+ // Lists Japanese, Korean, and Chinese sanserif fonts available in
+ // Windows XP and Vista, as well as "Arial Unicode MS".
+ return "MSGOTHIC.TTC;gulim.ttc;simhei.ttf;ArialUni.ttf";
+}
+
#endif // LL_WINDOWS
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index f6e40a1c7f..38836e0d81 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -116,6 +116,8 @@ public:
/*virtual*/ void updateLanguageTextInputArea();
/*virtual*/ void interruptLanguageTextInput();
+ static std::string getFontListSans();
+
protected:
LLWindowWin32(
char *title, char *name, int x, int y, int width, int height, U32 flags,