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

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

Issue 1757703003: Extend FontCache fallback API to support FontFallbackPriority (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 9 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* kColorEmojiFontMac = "Apple Color Emoji";
57
56 static void invalidateFontCache() 58 static void invalidateFontCache()
57 { 59 {
58 if (!isMainThread()) { 60 if (!isMainThread()) {
59 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER E, bind(&invalidateFontCache)); 61 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER E, bind(&invalidateFontCache));
60 return; 62 return;
61 } 63 }
62 FontCache::fontCache()->invalidate(); 64 FontCache::fontCache()->invalidate();
63 } 65 }
64 66
65 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) 67 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef)
(...skipping 14 matching lines...) Expand all
80 void FontCache::platformInit() 82 void FontCache::platformInit()
81 { 83 {
82 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); 84 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
83 } 85 }
84 86
85 static inline bool isAppKitFontWeightBold(NSInteger appKitFontWeight) 87 static inline bool isAppKitFontWeightBold(NSInteger appKitFontWeight)
86 { 88 {
87 return appKitFontWeight >= 7; 89 return appKitFontWeight >= 7;
88 } 90 }
89 91
90 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 character, const SimpleFontData* fontDataToSubsti tute) 92 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(
93 const FontDescription& fontDescription,
94 UChar32 character,
95 const SimpleFontData* fontDataToSubstitute,
96 FontFallbackPriority fallbackPriority)
91 { 97 {
98
99 if (fallbackPriority == FontFallbackPriority::EmojiEmoji) {
100 RefPtr<SimpleFontData> emojiFont = getFontData(fontDescription, AtomicSt ring(kColorEmojiFontMac));
101 if (emojiFont)
102 return emojiFont;
103 }
104
92 // FIXME: We should fix getFallbackFamily to take a UChar32 105 // FIXME: We should fix getFallbackFamily to take a UChar32
93 // and remove this split-to-UChar16 code. 106 // and remove this split-to-UChar16 code.
94 UChar codeUnits[2]; 107 UChar codeUnits[2];
95 int codeUnitsLength; 108 int codeUnitsLength;
96 if (character <= 0xFFFF) { 109 if (character <= 0xFFFF) {
97 codeUnits[0] = character; 110 codeUnits[0] = character;
98 codeUnitsLength = 1; 111 codeUnitsLength = 1;
99 } else { 112 } else {
100 codeUnits[0] = U16_LEAD(character); 113 codeUnits[0] = U16_LEAD(character);
101 codeUnits[1] = U16_TRAIL(character); 114 codeUnits[1] = U16_TRAIL(character);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // When loading fails, we do not want to use the returned FontPlatformData s ince it will not have 234 // When loading fails, we do not want to use the returned FontPlatformData s ince it will not have
222 // a valid SkTypeface. 235 // a valid SkTypeface.
223 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); 236 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation()));
224 if (!platformData->typeface()) { 237 if (!platformData->typeface()) {
225 return nullptr; 238 return nullptr;
226 } 239 }
227 return platformData.release(); 240 return platformData.release();
228 } 241 }
229 242
230 } // namespace blink 243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698