diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/llwindow/llwindowsdl.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/llwindow/llwindowsdl.cpp')
-rw-r--r-- | linden/indra/llwindow/llwindowsdl.cpp | 98 |
1 files changed, 95 insertions, 3 deletions
diff --git a/linden/indra/llwindow/llwindowsdl.cpp b/linden/indra/llwindow/llwindowsdl.cpp index d9dc040..0d1d622 100644 --- a/linden/indra/llwindow/llwindowsdl.cpp +++ b/linden/indra/llwindow/llwindowsdl.cpp | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "llgl.h" | 39 | #include "llgl.h" |
40 | #include "llstring.h" | 40 | #include "llstring.h" |
41 | #include "lldir.h" | 41 | #include "lldir.h" |
42 | #include "llfindlocale.h" | ||
42 | 43 | ||
43 | #include "llglheaders.h" | 44 | #include "llglheaders.h" |
44 | 45 | ||
@@ -51,6 +52,10 @@ extern "C" { | |||
51 | #include <locale.h> | 52 | #include <locale.h> |
52 | #endif // LL_GTK | 53 | #endif // LL_GTK |
53 | 54 | ||
55 | extern "C" { | ||
56 | # include "fontconfig/fontconfig.h" | ||
57 | } | ||
58 | |||
54 | #if LL_LINUX || LL_SOLARIS | 59 | #if LL_LINUX || LL_SOLARIS |
55 | // not necessarily available on random SDL platforms, so #if LL_LINUX | 60 | // not necessarily available on random SDL platforms, so #if LL_LINUX |
56 | // for execv(), waitpid(), fork() | 61 | // for execv(), waitpid(), fork() |
@@ -2030,7 +2035,8 @@ void LLWindowSDL::gatherInput() | |||
2030 | // the locale to protect it, as exotic/non-C locales | 2035 | // the locale to protect it, as exotic/non-C locales |
2031 | // causes our code lots of general critical weirdness | 2036 | // causes our code lots of general critical weirdness |
2032 | // and crashness. (SL-35450) | 2037 | // and crashness. (SL-35450) |
2033 | std::string saved_locale = setlocale(LC_ALL, NULL); | 2038 | static std::string saved_locale; |
2039 | saved_locale = ll_safe_string(setlocale(LC_ALL, NULL)); | ||
2034 | 2040 | ||
2035 | // Pump until we've nothing left to do or passed 1/15th of a | 2041 | // Pump until we've nothing left to do or passed 1/15th of a |
2036 | // second pumping for this frame. | 2042 | // second pumping for this frame. |
@@ -2751,8 +2757,8 @@ void spawn_web_browser(const char* escaped_url) | |||
2751 | # endif // LL_X11 | 2757 | # endif // LL_X11 |
2752 | 2758 | ||
2753 | std::string cmd; | 2759 | std::string cmd; |
2754 | cmd = gDirUtilp->getAppRODataDir().c_str(); | 2760 | cmd = gDirUtilp->getAppRODataDir(); |
2755 | cmd += gDirUtilp->getDirDelimiter().c_str(); | 2761 | cmd += gDirUtilp->getDirDelimiter(); |
2756 | cmd += "launch_url.sh"; | 2762 | cmd += "launch_url.sh"; |
2757 | char* const argv[] = {(char*)cmd.c_str(), (char*)escaped_url, NULL}; | 2763 | char* const argv[] = {(char*)cmd.c_str(), (char*)escaped_url, NULL}; |
2758 | 2764 | ||
@@ -2829,4 +2835,90 @@ void LLWindowSDL::bringToFront() | |||
2829 | #endif // LL_X11 | 2835 | #endif // LL_X11 |
2830 | } | 2836 | } |
2831 | 2837 | ||
2838 | //static | ||
2839 | std::string LLWindowSDL::getFontListSans() | ||
2840 | { | ||
2841 | // Use libfontconfig to find us a nice ordered list of fallback fonts | ||
2842 | // specific to this system. | ||
2843 | std::string final_fallback("/usr/share/fonts/truetype/kochi/kochi-gothic.ttf"); | ||
2844 | // Our 'ideal' font properties which define the sorting results. | ||
2845 | // slant=0 means Roman, index=0 means the first face in a font file | ||
2846 | // (the one we actually use), weight=80 means medium weight, | ||
2847 | // spacing=0 means proportional spacing. | ||
2848 | std::string sort_order("slant=0:index=0:weight=80:spacing=0"); | ||
2849 | // elide_unicode_coverage removes fonts from the list whose unicode | ||
2850 | // range is covered by fonts earlier in the list. This usually | ||
2851 | // removes ~90% of the fonts as redundant (which is great because | ||
2852 | // the font list can be huge), but might unnecessarily reduce the | ||
2853 | // renderable range if for some reason our FreeType actually fails | ||
2854 | // to use some of the fonts we want it to. | ||
2855 | const bool elide_unicode_coverage = true; | ||
2856 | std::string rtn; | ||
2857 | FcFontSet *fs = NULL; | ||
2858 | FcPattern *sortpat = NULL; | ||
2859 | int font_count = 0; | ||
2860 | |||
2861 | llinfos << "Getting system font list from FontConfig..." << llendl; | ||
2862 | |||
2863 | // If the user has a system-wide language preference, then favor | ||
2864 | // fonts from that language group. This doesn't affect the types | ||
2865 | // of languages that can be displayed, but ensures that their | ||
2866 | // preferred language is rendered from a single consistent font where | ||
2867 | // possible. | ||
2868 | FL_Locale *locale = NULL; | ||
2869 | FL_Success success = FL_FindLocale(&locale, FL_MESSAGES); | ||
2870 | if (success != 0) | ||
2871 | { | ||
2872 | if (success >= 2 && locale->lang) // confident! | ||
2873 | { | ||
2874 | llinfos << "Preferring fonts of language: " | ||
2875 | << locale->lang | ||
2876 | << llendl; | ||
2877 | sort_order = "lang=" + std::string(locale->lang) + ":" | ||
2878 | + sort_order; | ||
2879 | } | ||
2880 | FL_FreeLocale(&locale); | ||
2881 | } | ||
2882 | |||
2883 | if (!FcInit()) | ||
2884 | { | ||
2885 | llwarns << "FontConfig failed to initialize." << llendl; | ||
2886 | return final_fallback; | ||
2887 | } | ||
2888 | |||
2889 | sortpat = FcNameParse((FcChar8*) sort_order.c_str()); | ||
2890 | if (sortpat) | ||
2891 | { | ||
2892 | // Sort the list of system fonts from most-to-least-desirable. | ||
2893 | fs = FcFontSort(NULL, sortpat, elide_unicode_coverage, | ||
2894 | NULL, NULL); | ||
2895 | FcPatternDestroy(sortpat); | ||
2896 | } | ||
2897 | |||
2898 | if (fs) | ||
2899 | { | ||
2900 | // Get the full pathnames to the fonts, where available, | ||
2901 | // which is what we really want. | ||
2902 | int i; | ||
2903 | for (i=0; i<fs->nfont; ++i) | ||
2904 | { | ||
2905 | FcChar8 *filename; | ||
2906 | if (FcResultMatch == FcPatternGetString(fs->fonts[i], | ||
2907 | FC_FILE, 0, | ||
2908 | &filename) | ||
2909 | && filename) | ||
2910 | { | ||
2911 | rtn += std::string((const char*)filename)+";"; | ||
2912 | ++font_count; | ||
2913 | } | ||
2914 | } | ||
2915 | FcFontSetDestroy (fs); | ||
2916 | } | ||
2917 | |||
2918 | lldebugs << "Using font list: " << rtn << llendl; | ||
2919 | llinfos << "Using " << font_count << " system font(s)." << llendl; | ||
2920 | |||
2921 | return rtn + final_fallback; | ||
2922 | } | ||
2923 | |||
2832 | #endif // LL_SDL | 2924 | #endif // LL_SDL |