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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 FontPlatformData alternateFont(substituteFont, platformData.size(), | 179 FontPlatformData alternateFont(substituteFont, platformData.size(), |
180 syntheticBold, | 180 syntheticBold, |
181 (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTra
it), | 181 (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTra
it), |
182 platformData.orientation()); | 182 platformData.orientation()); |
183 | 183 |
184 return fontDataFromFontPlatformData(&alternateFont, DoNotRetain); | 184 return fontDataFromFontPlatformData(&alternateFont, DoNotRetain); |
185 } | 185 } |
186 | 186 |
187 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& fontDescription, ShouldRetain shouldRetain) | 187 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
ption& fontDescription, ShouldRetain shouldRetain) |
188 { | 188 { |
189 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::Construc
tFromLiteral)); | 189 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times")); |
190 | 190 |
191 // FIXME: Would be even better to somehow get the user's default font here.
For now we'll pick | 191 // FIXME: Would be even better to somehow get the user's default font here.
For now we'll pick |
192 // the default that the user would get without changing any prefs. | 192 // the default that the user would get without changing any prefs. |
193 RefPtr<SimpleFontData> simpleFontData = getFontData(fontDescription, timesSt
r, false, shouldRetain); | 193 RefPtr<SimpleFontData> simpleFontData = getFontData(fontDescription, timesSt
r, false, shouldRetain); |
194 if (simpleFontData) | 194 if (simpleFontData) |
195 return simpleFontData.release(); | 195 return simpleFontData.release(); |
196 | 196 |
197 // 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 |
198 // 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 |
199 // 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 |
200 // to avoid a crash at least. | 200 // to avoid a crash at least. |
201 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicS
tring::ConstructFromLiteral)); | 201 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande")); |
202 return getFontData(fontDescription, lucidaGrandeStr, false, shouldRetain); | 202 return getFontData(fontDescription, lucidaGrandeStr, false, shouldRetain); |
203 } | 203 } |
204 | 204 |
205 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip
tion& fontDescription, | 205 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip
tion& fontDescription, |
206 const FontFaceCreationParams& creationParams, float fontSize) | 206 const FontFaceCreationParams& creationParams, float fontSize) |
207 { | 207 { |
208 NSFontTraitMask traits = fontDescription.style() ? NSFontItalicTrait : 0; | 208 NSFontTraitMask traits = fontDescription.style() ? NSFontItalicTrait : 0; |
209 float size = fontSize; | 209 float size = fontSize; |
210 | 210 |
211 NSFont* nsFont = MatchNSFontFamily(creationParams.family(), traits, fontDesc
ription.weight(), size); | 211 NSFont* nsFont = MatchNSFontFamily(creationParams.family(), traits, fontDesc
ription.weight(), size); |
(...skipping 21 matching lines...) Expand all Loading... |
233 // When loading fails, we do not want to use the returned FontPlatformData s
ince it will not have | 233 // When loading fails, we do not want to use the returned FontPlatformData s
ince it will not have |
234 // a valid SkTypeface. | 234 // a valid SkTypeface. |
235 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); | 235 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); |
236 if (!platformData->typeface()) { | 236 if (!platformData->typeface()) { |
237 return nullptr; | 237 return nullptr; |
238 } | 238 } |
239 return platformData.release(); | 239 return platformData.release(); |
240 } | 240 } |
241 | 241 |
242 } // namespace blink | 242 } // namespace blink |
OLD | NEW |