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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe
nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) | 55 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe
nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) |
56 { | 56 { |
57 ASSERT_UNUSED(observer, observer == fontCache()); | 57 ASSERT_UNUSED(observer, observer == fontCache()); |
58 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi
cation)); | 58 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi
cation)); |
59 invalidateFontCache(0); | 59 invalidateFontCache(0); |
60 } | 60 } |
61 | 61 |
62 void FontCache::platformInit() | 62 void FontCache::platformInit() |
63 { | 63 { |
64 wkSetUpFontCache(); | 64 WKSetUpFontCache(); |
65 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this,
fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon
tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); | 65 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this,
fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon
tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); |
66 } | 66 } |
67 | 67 |
68 static int toAppKitFontWeight(FontWeight fontWeight) | 68 static int toAppKitFontWeight(FontWeight fontWeight) |
69 { | 69 { |
70 static int appKitFontWeights[] = { | 70 static int appKitFontWeights[] = { |
71 2, // FontWeight100 | 71 2, // FontWeight100 |
72 3, // FontWeight200 | 72 3, // FontWeight200 |
73 4, // FontWeight300 | 73 4, // FontWeight300 |
74 5, // FontWeight400 | 74 5, // FontWeight400 |
(...skipping 12 matching lines...) Expand all Loading... |
87 } | 87 } |
88 | 88 |
89 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
const UChar* characters, int length) | 89 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
const UChar* characters, int length) |
90 { | 90 { |
91 UChar32 character; | 91 UChar32 character; |
92 U16_GET(characters, 0, 0, length, character); | 92 U16_GET(characters, 0, 0, length, character); |
93 const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharac
ter(character)->platformData(); | 93 const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharac
ter(character)->platformData(); |
94 NSFont *nsFont = platformData.font(); | 94 NSFont *nsFont = platformData.font(); |
95 | 95 |
96 NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UCh
ar*>(characters) length:length freeWhenDone:NO]; | 96 NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UCh
ar*>(characters) length:length freeWhenDone:NO]; |
97 NSFont *substituteFont = wkGetFontInLanguageForRange(nsFont, string, NSMakeR
ange(0, length)); | 97 NSFont *substituteFont = WKGetFontInLanguageForRange(nsFont, string, NSMakeR
ange(0, length)); |
98 [string release]; | 98 [string release]; |
99 | 99 |
100 if (!substituteFont && length == 1) | 100 if (!substituteFont && length == 1) |
101 substituteFont = wkGetFontInLanguageForCharacter(nsFont, characters[0]); | 101 substituteFont = WKGetFontInLanguageForCharacter(nsFont, characters[0]); |
102 if (!substituteFont) | 102 if (!substituteFont) |
103 return 0; | 103 return 0; |
104 | 104 |
105 // Chromium can't render AppleColorEmoji. | 105 // Chromium can't render AppleColorEmoji. |
106 if ([[substituteFont familyName] isEqual:@"Apple Color Emoji"]) | 106 if ([[substituteFont familyName] isEqual:@"Apple Color Emoji"]) |
107 return 0; | 107 return 0; |
108 | 108 |
109 // Use the family name from the AppKit-supplied substitute font, requesting
the | 109 // Use the family name from the AppKit-supplied substitute font, requesting
the |
110 // traits, weight, and size we want. One way this does better than the origi
nal | 110 // traits, weight, and size we want. One way this does better than the origi
nal |
111 // AppKit request is that it takes synthetic bold and oblique into account. | 111 // AppKit request is that it takes synthetic bold and oblique into account. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. | 224 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. |
225 // In that case, we don't want to use the platformData. | 225 // In that case, we don't want to use the platformData. |
226 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique,
fontDescription.orientation(), fontDescription.widthVariant())); | 226 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique,
fontDescription.orientation(), fontDescription.widthVariant())); |
227 if (!platformData->font()) | 227 if (!platformData->font()) |
228 return 0; | 228 return 0; |
229 return platformData.leakPtr(); | 229 return platformData.leakPtr(); |
230 } | 230 } |
231 | 231 |
232 } // namespace WebCore | 232 } // namespace WebCore |
OLD | NEW |