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

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: 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 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 const char* kColorEmojiFontsMac[] = { "Apple Color Emoji" };
wkorman 2016/01/25 23:38:16 Is there a useful documentation comment we can add
drott 2016/02/02 17:28:28 Added comments on how to determine/update those, t
57 const char* kTextEmojiFontsMac[] = { "Hiragino Kaku Gothic ProN", "Zapf Dingbats ", "Apple Symbols" };
58 const char* kSymbolsAndMathFontsMac[] = { "Menlo", "Arial Unicode MS" };
59
56 static void invalidateFontCache() 60 static void invalidateFontCache()
57 { 61 {
58 if (!isMainThread()) { 62 if (!isMainThread()) {
59 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER E, bind(&invalidateFontCache)); 63 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER E, bind(&invalidateFontCache));
60 return; 64 return;
61 } 65 }
62 FontCache::fontCache()->invalidate(); 66 FontCache::fontCache()->invalidate();
63 } 67 }
64 68
65 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) 69 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. 213 // 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 214 // When loading fails, we do not want to use the returned FontPlatformData s ince it will not have
211 // a valid SkTypeface. 215 // a valid SkTypeface.
212 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); 216 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation()));
213 if (!platformData->typeface()) { 217 if (!platformData->typeface()) {
214 return nullptr; 218 return nullptr;
215 } 219 }
216 return platformData.release(); 220 return platformData.release();
217 } 221 }
218 222
223
224 const Vector<AtomicString> FontCache::platformFontListForFallbackPriority(FontFa llbackPriority fallbackPriority) const
225 {
226 Vector<AtomicString> returnVector;
227 switch (fallbackPriority) {
228 case FontFallbackPriority::EmojiEmoji:
229 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kColorEmojiFontsMac); ++i)
230 returnVector.append(kColorEmojiFontsMac[i]);
231 break;
232 case FontFallbackPriority::EmojiText:
233 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kTextEmojiFontsMac); ++i)
234 returnVector.append(kTextEmojiFontsMac[i]);
235 break;
236 case FontFallbackPriority::Math:
237 case FontFallbackPriority::Symbols:
238 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kSymbolsAndMathFontsMac); ++i)
239 returnVector.append(kSymbolsAndMathFontsMac[i]);
240 break;
241 default:
242 ASSERT_NOT_REACHED();
243 }
244 return returnVector;
245 }
246
247
219 } // namespace blink 248 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698