Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 | |
|
wkorman
2016/02/02 19:04:08
-1 blank
| |
| 229 const Vector<AtomicString> FontCache::platformFontListForFallbackPriority(FontFa llbackPriority fallbackPriority) const | |
| 230 { | |
| 231 Vector<AtomicString> returnVector; | |
| 232 switch (fallbackPriority) { | |
| 233 case FontFallbackPriority::EmojiEmoji: | |
| 234 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kColorEmojiFontsMac); ++i) | |
| 235 returnVector.append(kColorEmojiFontsMac[i]); | |
| 236 break; | |
| 237 case FontFallbackPriority::EmojiText: | |
| 238 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kTextEmojiFontsMac); ++i) | |
| 239 returnVector.append(kTextEmojiFontsMac[i]); | |
| 240 break; | |
| 241 case FontFallbackPriority::Math: | |
| 242 case FontFallbackPriority::Symbols: | |
| 243 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kSymbolsAndMathFontsMac); ++i) | |
| 244 returnVector.append(kSymbolsAndMathFontsMac[i]); | |
| 245 break; | |
| 246 default: | |
| 247 ASSERT_NOT_REACHED(); | |
| 248 } | |
| 249 return returnVector; | |
| 250 } | |
| 251 | |
|
wkorman
2016/02/02 19:04:08
-1 blank
| |
| 252 | |
| 219 } // namespace blink | 253 } // namespace blink |
| OLD | NEW |