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

Unified Diff: third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp

Issue 1615923004: Add FontCache API for retrieving prioritized fallback fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
Index: third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp b/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp
index 591ba4f2cbf8872ef6eac5ec127e8ec2ee268ed0..361e8b927a454fc6d77ed9fb5b75fdb87c663a77 100644
--- a/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp
+++ b/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp
@@ -43,6 +43,26 @@
#include "wtf/text/CString.h"
#include <unicode/locid.h>
+#if OS(WIN)
+const char* kColorEmojiFonts[] = { "Segoe UI Emoji" };
+const char* kTextEmojiFonts[] = { "Segoe UI Symbol" };
+const char* kSymbolsFonts[] = { "Segoe UI Symbol" };
+const char* kMathFonts[] = { "Cambria Math", "Segoe UI Symbol", "Code2000" };
+#elif OS(ANDROID)
+// Due to crbug.com/322658 we cannot properly specifiy Android font family names here,
wkorman 2016/01/25 23:38:16 specify
drott 2016/02/02 17:28:28 Done.
+// The way Skia's SkFontMgr_android gives them canonical names, we can however
+// reference the Noto Color Emoji font under "56##fallback" on Android 6.0.1
+const char* kColorEmojiFonts[] = { "56##fallback", "Noto Color Emoji", "Android Emoji" };
+const char* kTextEmojiFonts[] = { "Droid Sans Fallback" };
+const char* kSymbolsFonts[] = { "Droid Sans Fallback" };
+const char* kMathFonts[] = { "Droid Sans Fallback" };
+#elif OS(LINUX)
+const char* kColorEmojiFonts[] = { "Noto Color Emoji", "Noto Sans Symbols", "Symbola" };
+const char* kTextEmojiFonts[] = { "Noto Sans Symbols", "Symbola" };
+const char* kSymbolsFonts[] = { "FreeSerif", "FreeMono" };
+const char* kMathFonts[] = { "FreeSerif", "FreeMono" };
+#endif
+
#if !OS(WIN) && !OS(ANDROID)
#include "SkFontConfigInterface.h"
@@ -161,6 +181,33 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
}
+
+const Vector<AtomicString> FontCache::platformFontListForFallbackPriority(FontFallbackPriority fallbackPriority) const
+{
+ Vector<AtomicString> returnVector;
+ switch (fallbackPriority) {
+ case FontFallbackPriority::EmojiEmoji:
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(kColorEmojiFonts); ++i)
+ returnVector.append(kColorEmojiFonts[i]);
+ break;
+ case FontFallbackPriority::EmojiText:
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(kTextEmojiFonts); ++i)
+ returnVector.append(kTextEmojiFonts[i]);
+ break;
+ case FontFallbackPriority::Math:
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(kMathFonts); ++i)
+ returnVector.append(kMathFonts[i]);
+ break;
+ case FontFallbackPriority::Symbols:
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(kSymbolsFonts); ++i)
+ returnVector.append(kSymbolsFonts[i]);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return returnVector;
+}
+
#if OS(WIN)
static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
{

Powered by Google App Engine
This is Rietveld 408576698