| 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 16 matching lines...) Expand all Loading... |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #import "config.h" | 30 #import "config.h" |
| 31 #import "platform/fonts/FontCache.h" | 31 #import "platform/fonts/FontCache.h" |
| 32 | 32 |
| 33 #import <AppKit/AppKit.h> | 33 #import <AppKit/AppKit.h> |
| 34 #import "platform/LayoutTestSupport.h" | 34 #import "platform/LayoutTestSupport.h" |
| 35 #import "platform/RuntimeEnabledFeatures.h" | 35 #import "platform/RuntimeEnabledFeatures.h" |
| 36 #import "platform/fonts/FontDescription.h" | 36 #import "platform/fonts/FontDescription.h" |
| 37 #import "platform/fonts/FontFaceCreationParams.h" |
| 37 #import "platform/fonts/FontPlatformData.h" | 38 #import "platform/fonts/FontPlatformData.h" |
| 38 #import "platform/fonts/SimpleFontData.h" | 39 #import "platform/fonts/SimpleFontData.h" |
| 39 #import "platform/mac/WebFontCache.h" | 40 #import "platform/mac/WebFontCache.h" |
| 40 #import <wtf/MainThread.h> | 41 #import <wtf/MainThread.h> |
| 41 #import <wtf/StdLibExtras.h> | 42 #import <wtf/StdLibExtras.h> |
| 42 | 43 |
| 43 // Forward declare Mac SPIs. | 44 // Forward declare Mac SPIs. |
| 44 // Request for public API: rdar://13803570 | 45 // Request for public API: rdar://13803570 |
| 45 @interface NSFont (WebKitSPI) | 46 @interface NSFont (WebKitSPI) |
| 46 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR
ange)range inLanguage:(id)useNil; | 47 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR
ange)range inLanguage:(id)useNil; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return simpleFontData.release(); | 195 return simpleFontData.release(); |
| 195 | 196 |
| 196 // The Times fallback will almost always work, but in the highly unusual cas
e where | 197 // The Times fallback will almost always work, but in the highly unusual cas
e where |
| 197 // the user doesn't have it, we fall back on Lucida Grande because that's | 198 // the user doesn't have it, we fall back on Lucida Grande because that's |
| 198 // guaranteed to be there, according to Nathan Taylor. This is good enough | 199 // guaranteed to be there, according to Nathan Taylor. This is good enough |
| 199 // to avoid a crash at least. | 200 // to avoid a crash at least. |
| 200 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicS
tring::ConstructFromLiteral)); | 201 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicS
tring::ConstructFromLiteral)); |
| 201 return getFontData(fontDescription, lucidaGrandeStr, false, shouldRetain); | 202 return getFontData(fontDescription, lucidaGrandeStr, false, shouldRetain); |
| 202 } | 203 } |
| 203 | 204 |
| 204 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
escription, const AtomicString& family, float fontSize) | 205 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
escription, const FontFaceCreationParams& creationParams, float fontSize) |
| 205 { | 206 { |
| 206 NSFontTraitMask traits = fontDescription.style() ? NSFontItalicTrait : 0; | 207 NSFontTraitMask traits = fontDescription.style() ? NSFontItalicTrait : 0; |
| 207 NSInteger weight = toAppKitFontWeight(fontDescription.weight()); | 208 NSInteger weight = toAppKitFontWeight(fontDescription.weight()); |
| 208 float size = fontSize; | 209 float size = fontSize; |
| 209 | 210 |
| 210 NSFont *nsFont = [WebFontCache fontWithFamily:family traits:traits weight:we
ight size:size]; | 211 NSFont *nsFont = [WebFontCache fontWithFamily:creationParams.family() traits
:traits weight:weight size:size]; |
| 211 if (!nsFont) | 212 if (!nsFont) |
| 212 return 0; | 213 return 0; |
| 213 | 214 |
| 214 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 215 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 215 NSFontTraitMask actualTraits = 0; | 216 NSFontTraitMask actualTraits = 0; |
| 216 if (fontDescription.style()) | 217 if (fontDescription.style()) |
| 217 actualTraits = [fontManager traitsOfFont:nsFont]; | 218 actualTraits = [fontManager traitsOfFont:nsFont]; |
| 218 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; | 219 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; |
| 219 | 220 |
| 220 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF
ont]; | 221 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF
ont]; |
| 221 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); | 222 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB
old(actualWeight)) || fontDescription.isSyntheticBold(); |
| 222 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS
FontItalicTrait)) || fontDescription.isSyntheticItalic(); | 223 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS
FontItalicTrait)) || fontDescription.isSyntheticItalic(); |
| 223 | 224 |
| 224 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. | 225 // 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. | 226 // In that case, we don't want to use the platformData. |
| 226 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticOblique, fontDescription.orientation(), fo
ntDescription.widthVariant())); | 227 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticOblique, fontDescription.orientation(), fo
ntDescription.widthVariant())); |
| 227 if (!platformData->font()) | 228 if (!platformData->font()) |
| 228 return 0; | 229 return 0; |
| 229 return platformData.leakPtr(); | 230 return platformData.leakPtr(); |
| 230 } | 231 } |
| 231 | 232 |
| 232 } // namespace WebCore | 233 } // namespace WebCore |
| OLD | NEW |