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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Forward declare Mac SPIs. 47 // Forward declare Mac SPIs.
48 // Request for public API: rdar://13803570 48 // Request for public API: rdar://13803570
49 @interface NSFont (WebKitSPI) 49 @interface NSFont (WebKitSPI)
50 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR ange)range inLanguage:(id)useNil; 50 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR ange)range inLanguage:(id)useNil;
51 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us eNil; 51 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us eNil;
52 @end 52 @end
53 53
54 namespace blink { 54 namespace blink {
55 55
56 // Unfortunately, these chosen font names require a bit of experimentation and
57 // researching on the respective platforms as to what works best and is widely
58 // available. They may require further tuning after OS updates. Mozilla's
59 // choices in the gfxPlatformMac::GetCommonFallbackFonts method collects some of
60 // the outcome of this experimentation.
61 const char* kColorEmojiFontsMac[] = { "Apple Color Emoji" };
62 const char* kTextEmojiFontsMac[] = { "Hiragino Kaku Gothic ProN", "Zapf Dingbats ", "Apple Symbols" };
63 const char* kSymbolsAndMathFontsMac[] = { "Menlo", "Arial Unicode MS" };
64
56 static void invalidateFontCache() 65 static void invalidateFontCache()
57 { 66 {
58 if (!isMainThread()) { 67 if (!isMainThread()) {
59 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER E, bind(&invalidateFontCache)); 68 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER E, bind(&invalidateFontCache));
60 return; 69 return;
61 } 70 }
62 FontCache::fontCache()->invalidate(); 71 FontCache::fontCache()->invalidate();
63 } 72 }
64 73
65 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) 74 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Out-of-process loading occurs for registered fonts stored in non-system l ocations. 218 // Out-of-process loading occurs for registered fonts stored in non-system l ocations.
210 // When loading fails, we do not want to use the returned FontPlatformData s ince it will not have 219 // When loading fails, we do not want to use the returned FontPlatformData s ince it will not have
211 // a valid SkTypeface. 220 // a valid SkTypeface.
212 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); 221 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation()));
213 if (!platformData->typeface()) { 222 if (!platformData->typeface()) {
214 return nullptr; 223 return nullptr;
215 } 224 }
216 return platformData.release(); 225 return platformData.release();
217 } 226 }
218 227
228 const Vector<AtomicString> FontCache::platformFontListForFallbackPriority(FontFa llbackPriority fallbackPriority) const
229 {
230 Vector<AtomicString> returnVector;
231 switch (fallbackPriority) {
232 case FontFallbackPriority::EmojiEmoji:
233 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kColorEmojiFontsMac); ++i)
234 returnVector.append(kColorEmojiFontsMac[i]);
235 break;
236 case FontFallbackPriority::EmojiText:
237 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kTextEmojiFontsMac); ++i)
238 returnVector.append(kTextEmojiFontsMac[i]);
239 break;
240 case FontFallbackPriority::Math:
241 case FontFallbackPriority::Symbols:
242 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kSymbolsAndMathFontsMac); ++i)
243 returnVector.append(kSymbolsAndMathFontsMac[i]);
244 break;
245 default:
246 ASSERT_NOT_REACHED();
247 }
248 return returnVector;
249 }
250
219 } // namespace blink 251 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698