Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: sky/engine/platform/fonts/android/FontCacheAndroid.cpp

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/platform/fonts/FontCache.h ('k') | sky/viewer/platform/weblayertreeview_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/platform/fonts/android/FontCacheAndroid.cpp
diff --git a/sky/engine/platform/fonts/android/FontCacheAndroid.cpp b/sky/engine/platform/fonts/android/FontCacheAndroid.cpp
index 8f070e8603027de4758b8e4caef8cded2df45bdd..25c4c75952334abb3ac35a654647c846e25eb5b0 100644
--- a/sky/engine/platform/fonts/android/FontCacheAndroid.cpp
+++ b/sky/engine/platform/fonts/android/FontCacheAndroid.cpp
@@ -31,7 +31,7 @@
#include "config.h"
#include "platform/fonts/FontCache.h"
-
+#include "platform/Language.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/FontFaceCreationParams.h"
@@ -40,31 +40,19 @@
namespace blink {
-static AtomicString getFamilyNameForCharacter(UChar32 c, UScriptCode script)
+static AtomicString getFamilyNameForCharacter(UChar32 c, const FontDescription& fontDescription)
{
- // This is a hack to use the preferred font for CJK scripts.
- // FIXME: Use new Skia API once Android system supports per-family and per-script fallback fonts.
- const char* locale;
- switch (script) {
- case USCRIPT_SIMPLIFIED_HAN:
- locale = "zh-CN";
- break;
- case USCRIPT_TRADITIONAL_HAN:
- locale = "zh-TW";
- break;
- case USCRIPT_KATAKANA_OR_HIRAGANA:
- locale = "ja";
- break;
- case USCRIPT_HANGUL:
- locale = "ko";
- break;
- default:
- locale = 0;
- break;
- }
-
RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
- RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFontStyle(), locale, c));
+ const char* bcp47Locales[2];
+ int localeCount = 0;
+ CString defaultLocale = defaultLanguage().ascii();
+ bcp47Locales[localeCount++] = defaultLocale.data();
+ CString fontLocale;
+ if (!fontDescription.locale().isEmpty()) {
+ fontLocale = fontDescription.locale().ascii();
+ bcp47Locales[localeCount++] = fontLocale.data();
+ }
+ RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFontStyle(), bcp47Locales, localeCount, c));
if (!typeface)
return emptyAtom;
@@ -75,19 +63,19 @@ static AtomicString getFamilyNameForCharacter(UChar32 c, UScriptCode script)
PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescription& fontDescription, UChar32 c, const SimpleFontData*)
{
- AtomicString familyName = getFamilyNameForCharacter(c, fontDescription.script());
+ AtomicString familyName = getFamilyNameForCharacter(c, fontDescription);
if (familyName.isEmpty())
return getLastResortFallbackFont(fontDescription, DoNotRetain);
return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, FontFaceCreationParams(familyName)), DoNotRetain);
}
// static
-AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& familyName, UScriptCode script)
+AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& familyName, const FontDescription& fontDescription)
{
// This is a hack to use the preferred font for CJK scripts.
// FIXME: Use new Skia API once Android system supports per-family and per-script fallback fonts.
UChar32 examplerChar;
- switch (script) {
+ switch (fontDescription.script()) {
case USCRIPT_SIMPLIFIED_HAN:
case USCRIPT_TRADITIONAL_HAN:
case USCRIPT_KATAKANA_OR_HIRAGANA:
@@ -101,7 +89,7 @@ AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& family
return familyName;
}
- return getFamilyNameForCharacter(examplerChar, script);
+ return getFamilyNameForCharacter(examplerChar, fontDescription);
}
} // namespace blink
« no previous file with comments | « sky/engine/platform/fonts/FontCache.h ('k') | sky/viewer/platform/weblayertreeview_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698