--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -5,16 +5,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "gfxAndroidPlatform.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/CountingAllocatorBase.h"
#include "mozilla/intl/LocaleService.h"
+#include "mozilla/intl/OSPreferences.h"
#include "mozilla/Preferences.h"
#include "gfx2DGlue.h"
#include "gfxFT2FontList.h"
#include "gfxImageSurface.h"
#include "gfxTextRun.h"
#include "mozilla/dom/ContentChild.h"
#include "nsXULAppAPI.h"
@@ -30,16 +31,17 @@
#include FT_MODULE_H
#include "GeneratedJNINatives.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
using mozilla::intl::LocaleService;
+using mozilla::intl::OSPreferences;
static FT_Library gPlatformFTLibrary = nullptr;
class FreetypeReporter final : public nsIMemoryReporter,
public CountingAllocatorBase<FreetypeReporter>
{
private:
~FreetypeReporter() {}
@@ -134,16 +136,23 @@ IsJapaneseLocale()
sInitialized = true;
nsAutoCString appLocale;
LocaleService::GetInstance()->GetAppLocaleAsLangTag(appLocale);
const nsDependentCSubstring lang(appLocale, 0, 2);
if (lang.EqualsLiteral("ja")) {
sIsJapanese = true;
+ } else {
+ OSPreferences::GetInstance()->GetSystemLocale(appLocale);
+
+ const nsDependentCSubstring lang(appLocale, 0, 2);
+ if (lang.EqualsLiteral("ja")) {
+ sIsJapanese = true;
+ }
}
}
return sIsJapanese;
}
void
gfxAndroidPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -1,15 +1,16 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Logging.h"
#include "mozilla/intl/LocaleService.h"
+#include "mozilla/intl/OSPreferences.h"
#include "gfxPlatformFontList.h"
#include "gfxTextRun.h"
#include "gfxUserFontSet.h"
#include "nsCRT.h"
#include "nsGkAtoms.h"
#include "nsServiceManagerUtils.h"
@@ -24,16 +25,17 @@
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/gfx/2D.h"
#include <locale.h>
using namespace mozilla;
using mozilla::intl::LocaleService;
+using mozilla::intl::OSPreferences;
#define LOG_FONTLIST(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \
LogLevel::Debug, args)
#define LOG_FONTLIST_ENABLED() MOZ_LOG_TEST( \
gfxPlatform::GetLog(eGfxLog_fontlist), \
LogLevel::Debug)
#define LOG_FONTINIT(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontinit), \
LogLevel::Debug, args)
@@ -1086,33 +1088,57 @@ gfxPlatformFontList::AppendCJKPrefLangs(
break;
default:
break;
}
p++;
}
}
+ // Try using app's locale
nsAutoCString localeStr;
LocaleService::GetInstance()->GetAppLocaleAsLangTag(localeStr);
- const nsACString& lang = Substring(localeStr, 0, 2);
- if (lang.EqualsLiteral("ja")) {
- AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
- } else if (lang.EqualsLiteral("zh")) {
- const nsACString& region = Substring(localeStr, 3, 2);
- if (region.EqualsLiteral("CN")) {
- AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
- } else if (region.EqualsLiteral("TW")) {
- AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
- } else if (region.EqualsLiteral("HK")) {
- AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
- }
- } else if (lang.EqualsLiteral("ko")) {
- AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
+ {
+ const nsACString& lang = Substring(localeStr, 0, 2);
+ if (lang.EqualsLiteral("ja")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
+ } else if (lang.EqualsLiteral("zh")) {
+ const nsACString& region = Substring(localeStr, 3, 2);
+ if (region.EqualsLiteral("CN")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
+ } else if (region.EqualsLiteral("TW")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
+ } else if (region.EqualsLiteral("HK")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
+ }
+ } else if (lang.EqualsLiteral("ko")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
+ }
+ }
+
+ // Then test OS locale
+ OSPreferences::GetInstance()->GetSystemLocale(localeStr);
+
+ {
+ const nsACString& lang = Substring(localeStr, 0, 2);
+ if (lang.EqualsLiteral("ja")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
+ } else if (lang.EqualsLiteral("zh")) {
+ const nsACString& region = Substring(localeStr, 3, 2);
+ if (region.EqualsLiteral("CN")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
+ } else if (region.EqualsLiteral("TW")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
+ } else if (region.EqualsLiteral("HK")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
+ }
+ } else if (lang.EqualsLiteral("ko")) {
+ AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
+ }
}
// last resort... (the order is same as old gfx.)
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);