| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // The "void*" parameter makes the function match the prototype for callbacks fr
om callOnMainThread. | 45 // The "void*" parameter makes the function match the prototype for callbacks fr
om callOnMainThread. |
| 46 static void invalidateFontCache(void*) | 46 static void invalidateFontCache(void*) |
| 47 { | 47 { |
| 48 if (!isMainThread()) { | 48 if (!isMainThread()) { |
| 49 callOnMainThread(&invalidateFontCache, 0); | 49 callOnMainThread(&invalidateFontCache, 0); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 fontCache()->invalidate(); | 52 fontCache()->invalidate(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
| 56 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) |
| 57 { | 56 { |
| 58 ASSERT_UNUSED(observer, observer == fontCache()); | 57 ASSERT_UNUSED(observer, observer == fontCache()); |
| 59 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi
cation)); | 58 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi
cation)); |
| 60 invalidateFontCache(0); | 59 invalidateFontCache(0); |
| 61 } | 60 } |
| 62 #else | |
| 63 static void fontCacheATSNotificationCallback(ATSFontNotificationInfoRef, void*) | |
| 64 { | |
| 65 invalidateFontCache(0); | |
| 66 } | |
| 67 #endif | |
| 68 | 61 |
| 69 void FontCache::platformInit() | 62 void FontCache::platformInit() |
| 70 { | 63 { |
| 71 wkSetUpFontCache(); | 64 wkSetUpFontCache(); |
| 72 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
| 73 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this,
fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon
tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); | 65 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this,
fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon
tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); |
| 74 #else | |
| 75 // kCTFontManagerRegisteredFontsChangedNotification does not exist on Leopar
d and earlier. | |
| 76 // FIXME: Passing kATSFontNotifyOptionReceiveWhileSuspended may be an overki
ll and does not seem to work anyway. | |
| 77 ATSFontNotificationSubscribe(fontCacheATSNotificationCallback, kATSFontNotif
yOptionReceiveWhileSuspended, 0, 0); | |
| 78 #endif | |
| 79 } | 66 } |
| 80 | 67 |
| 81 static int toAppKitFontWeight(FontWeight fontWeight) | 68 static int toAppKitFontWeight(FontWeight fontWeight) |
| 82 { | 69 { |
| 83 static int appKitFontWeights[] = { | 70 static int appKitFontWeights[] = { |
| 84 2, // FontWeight100 | 71 2, // FontWeight100 |
| 85 3, // FontWeight200 | 72 3, // FontWeight200 |
| 86 4, // FontWeight300 | 73 4, // FontWeight300 |
| 87 5, // FontWeight400 | 74 5, // FontWeight400 |
| 88 6, // FontWeight500 | 75 6, // FontWeight500 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 223 |
| 237 // 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. |
| 238 // In that case, we don't want to use the platformData. | 225 // In that case, we don't want to use the platformData. |
| 239 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())); |
| 240 if (!platformData->font()) | 227 if (!platformData->font()) |
| 241 return 0; | 228 return 0; |
| 242 return platformData.leakPtr(); | 229 return platformData.leakPtr(); |
| 243 } | 230 } |
| 244 | 231 |
| 245 } // namespace WebCore | 232 } // namespace WebCore |
| OLD | NEW |