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

Unified Diff: third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm

Issue 1615923004: Add FontCache API for retrieving prioritized fallback fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documenting public method Created 4 years, 10 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/mac/FontCacheMac.mm
diff --git a/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm b/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
index 0ea373417959f4aa4d374ba9457769928ce2d893..629b7eb5898546dfbd79361cc4096463330f4658 100644
--- a/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
+++ b/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
@@ -53,6 +53,15 @@
namespace blink {
+// Unfortunately, these chosen font names require a bit of experimentation and
+// researching on the respective platforms as to what works best and is widely
+// available. They may require further tuning after OS updates. Mozilla's
+// choices in the gfxPlatformMac::GetCommonFallbackFonts method collects some of
+// the outcome of this experimentation.
+const char* kColorEmojiFontsMac[] = { "Apple Color Emoji" };
+const char* kTextEmojiFontsMac[] = { "Hiragino Kaku Gothic ProN", "Zapf Dingbats", "Apple Symbols" };
+const char* kSymbolsAndMathFontsMac[] = { "Menlo", "Arial Unicode MS" };
+
static void invalidateFontCache()
{
if (!isMainThread()) {
@@ -216,4 +225,27 @@ PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip
return platformData.release();
}
+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(kColorEmojiFontsMac); ++i)
+ returnVector.append(kColorEmojiFontsMac[i]);
+ break;
+ case FontFallbackPriority::EmojiText:
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(kTextEmojiFontsMac); ++i)
+ returnVector.append(kTextEmojiFontsMac[i]);
+ break;
+ case FontFallbackPriority::Math:
+ case FontFallbackPriority::Symbols:
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(kSymbolsAndMathFontsMac); ++i)
+ returnVector.append(kSymbolsAndMathFontsMac[i]);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return returnVector;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698