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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicS tring::ConstructFromLiteral)); | 190 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicS tring::ConstructFromLiteral)); |
191 return getFontData(fontDescription, lucidaGrandeStr, false, shouldRetain); | 191 return getFontData(fontDescription, lucidaGrandeStr, false, shouldRetain); |
192 } | 192 } |
193 | 193 |
194 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family, float fontSize) | 194 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family, float fontSize) |
195 { | 195 { |
196 NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0; | 196 NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0; |
197 NSInteger weight = toAppKitFontWeight(fontDescription.weight()); | 197 NSInteger weight = toAppKitFontWeight(fontDescription.weight()); |
198 float size = fontSize; | 198 float size = fontSize; |
199 | 199 |
200 NSFont *nsFont = [WebFontCache fontWithFamily:family traits:traits weight:we ight size:size]; | 200 NSString *nsFontFamily = [[NSString alloc] initWithUTF8String:family.utf8(). data()]; |
Nico
2014/01/15 19:06:12
This isn't correct, this is never freed anywhere.
tasak
2014/01/17 08:17:29
Done.
| |
201 NSFont *nsFont = [WebFontCache fontWithFamily:nsFontFamily traits:traits wei ght:weight size:size]; | |
201 if (!nsFont) | 202 if (!nsFont) |
202 return 0; | 203 return 0; |
203 | 204 |
204 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 205 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
205 NSFontTraitMask actualTraits = 0; | 206 NSFontTraitMask actualTraits = 0; |
206 if (fontDescription.italic()) | 207 if (fontDescription.italic()) |
207 actualTraits = [fontManager traitsOfFont:nsFont]; | 208 actualTraits = [fontManager traitsOfFont:nsFont]; |
208 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; | 209 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; |
209 | 210 |
210 NSFont *platformFont = fontDescription.usePrinterFont() ? [nsFont printerFon t] : [nsFont screenFont]; | 211 NSFont *platformFont = fontDescription.usePrinterFont() ? [nsFont printerFon t] : [nsFont screenFont]; |
211 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB old(actualWeight)) || fontDescription.isSyntheticBold(); | 212 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB old(actualWeight)) || fontDescription.isSyntheticBold(); |
212 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS FontItalicTrait)) || fontDescription.isSyntheticItalic(); | 213 bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NS FontItalicTrait)) || fontDescription.isSyntheticItalic(); |
213 | 214 |
214 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. | 215 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. |
215 // In that case, we don't want to use the platformData. | 216 // In that case, we don't want to use the platformData. |
216 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant())); | 217 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant())); |
217 if (!platformData->font()) | 218 if (!platformData->font()) |
218 return 0; | 219 return 0; |
219 return platformData.leakPtr(); | 220 return platformData.leakPtr(); |
220 } | 221 } |
221 | 222 |
222 } // namespace WebCore | 223 } // namespace WebCore |
OLD | NEW |