| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 3 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
| 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 are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 return nullptr; | 138 return nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont( | 141 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont( |
| 142 const FontDescription& description, | 142 const FontDescription& description, |
| 143 ShouldRetain shouldRetain) { | 143 ShouldRetain shouldRetain) { |
| 144 const FontFaceCreationParams fallbackCreationParams( | 144 const FontFaceCreationParams fallbackCreationParams( |
| 145 getFallbackFontFamily(description)); | 145 getFallbackFontFamily(description)); |
| 146 const FontPlatformData* fontPlatformData = | 146 const FontPlatformData* fontPlatformData = getFontPlatformData( |
| 147 getFontPlatformData(description, fallbackCreationParams); | 147 description, fallbackCreationParams, AlternateFontName::LastResort); |
| 148 | 148 |
| 149 // We should at least have Sans or Arial which is the last resort fallback of | 149 // We should at least have Sans or Arial which is the last resort fallback of |
| 150 // SkFontHost ports. | 150 // SkFontHost ports. |
| 151 if (!fontPlatformData) { | 151 if (!fontPlatformData) { |
| 152 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, sansCreationParams, | 152 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, sansCreationParams, |
| 153 (AtomicString("Sans"))); | 153 (AtomicString("Sans"))); |
| 154 fontPlatformData = getFontPlatformData(description, sansCreationParams); | 154 fontPlatformData = getFontPlatformData(description, sansCreationParams, |
| 155 AlternateFontName::LastResort); |
| 155 } | 156 } |
| 156 if (!fontPlatformData) { | 157 if (!fontPlatformData) { |
| 157 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, arialCreationParams, | 158 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, arialCreationParams, |
| 158 (AtomicString("Arial"))); | 159 (AtomicString("Arial"))); |
| 159 fontPlatformData = getFontPlatformData(description, arialCreationParams); | 160 fontPlatformData = getFontPlatformData(description, arialCreationParams, |
| 161 AlternateFontName::LastResort); |
| 160 } | 162 } |
| 161 #if OS(WIN) | 163 #if OS(WIN) |
| 162 // Try some more Windows-specific fallbacks. | 164 // Try some more Windows-specific fallbacks. |
| 163 if (!fontPlatformData) { | 165 if (!fontPlatformData) { |
| 164 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, msuigothicCreationParams, | 166 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, msuigothicCreationParams, |
| 165 (AtomicString("MS UI Gothic"))); | 167 (AtomicString("MS UI Gothic"))); |
| 166 fontPlatformData = | 168 fontPlatformData = getFontPlatformData( |
| 167 getFontPlatformData(description, msuigothicCreationParams); | 169 description, msuigothicCreationParams, AlternateFontName::LastResort); |
| 168 } | 170 } |
| 169 if (!fontPlatformData) { | 171 if (!fontPlatformData) { |
| 170 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationParams, | 172 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationParams, |
| 171 (AtomicString("Microsoft Sans Serif"))); | 173 (AtomicString("Microsoft Sans Serif"))); |
| 172 fontPlatformData = | 174 fontPlatformData = getFontPlatformData( |
| 173 getFontPlatformData(description, mssansserifCreationParams); | 175 description, mssansserifCreationParams, AlternateFontName::LastResort); |
| 174 } | 176 } |
| 175 if (!fontPlatformData) { | 177 if (!fontPlatformData) { |
| 176 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, segoeuiCreationParams, | 178 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, segoeuiCreationParams, |
| 177 (AtomicString("Segoe UI"))); | 179 (AtomicString("Segoe UI"))); |
| 178 fontPlatformData = getFontPlatformData(description, segoeuiCreationParams); | 180 fontPlatformData = getFontPlatformData(description, segoeuiCreationParams, |
| 181 AlternateFontName::LastResort); |
| 179 } | 182 } |
| 180 if (!fontPlatformData) { | 183 if (!fontPlatformData) { |
| 181 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, calibriCreationParams, | 184 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, calibriCreationParams, |
| 182 (AtomicString("Calibri"))); | 185 (AtomicString("Calibri"))); |
| 183 fontPlatformData = getFontPlatformData(description, calibriCreationParams); | 186 fontPlatformData = getFontPlatformData(description, calibriCreationParams, |
| 187 AlternateFontName::LastResort); |
| 184 } | 188 } |
| 185 if (!fontPlatformData) { | 189 if (!fontPlatformData) { |
| 186 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, | 190 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, |
| 187 timesnewromanCreationParams, | 191 timesnewromanCreationParams, |
| 188 (AtomicString("Times New Roman"))); | 192 (AtomicString("Times New Roman"))); |
| 189 fontPlatformData = | 193 fontPlatformData = |
| 190 getFontPlatformData(description, timesnewromanCreationParams); | 194 getFontPlatformData(description, timesnewromanCreationParams, |
| 195 AlternateFontName::LastResort); |
| 191 } | 196 } |
| 192 if (!fontPlatformData) { | 197 if (!fontPlatformData) { |
| 193 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, couriernewCreationParams, | 198 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, couriernewCreationParams, |
| 194 (AtomicString("Courier New"))); | 199 (AtomicString("Courier New"))); |
| 195 fontPlatformData = | 200 fontPlatformData = getFontPlatformData( |
| 196 getFontPlatformData(description, couriernewCreationParams); | 201 description, couriernewCreationParams, AlternateFontName::LastResort); |
| 197 } | 202 } |
| 198 #endif | 203 #endif |
| 199 | 204 |
| 200 ASSERT(fontPlatformData); | 205 ASSERT(fontPlatformData); |
| 201 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); | 206 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); |
| 202 } | 207 } |
| 203 | 208 |
| 204 sk_sp<SkTypeface> FontCache::createTypeface( | 209 sk_sp<SkTypeface> FontCache::createTypeface( |
| 205 const FontDescription& fontDescription, | 210 const FontDescription& fontDescription, |
| 206 const FontFaceCreationParams& creationParams, | 211 const FontFaceCreationParams& creationParams, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // legacyCreateTypeface on all platforms. | 254 // legacyCreateTypeface on all platforms. |
| 250 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 255 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 251 return sk_sp<SkTypeface>( | 256 return sk_sp<SkTypeface>( |
| 252 fm->legacyCreateTypeface(name.data(), fontDescription.skiaFontStyle())); | 257 fm->legacyCreateTypeface(name.data(), fontDescription.skiaFontStyle())); |
| 253 } | 258 } |
| 254 | 259 |
| 255 #if !OS(WIN) | 260 #if !OS(WIN) |
| 256 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData( | 261 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData( |
| 257 const FontDescription& fontDescription, | 262 const FontDescription& fontDescription, |
| 258 const FontFaceCreationParams& creationParams, | 263 const FontFaceCreationParams& creationParams, |
| 259 float fontSize) { | 264 float fontSize, |
| 265 AlternateFontName) { |
| 260 CString name; | 266 CString name; |
| 261 sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name); | 267 sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name); |
| 262 if (!tf) | 268 if (!tf) |
| 263 return nullptr; | 269 return nullptr; |
| 264 | 270 |
| 265 return WTF::wrapUnique(new FontPlatformData( | 271 return WTF::wrapUnique(new FontPlatformData( |
| 266 tf, name.data(), fontSize, (numericFontWeight(fontDescription.weight()) > | 272 tf, name.data(), fontSize, (numericFontWeight(fontDescription.weight()) > |
| 267 200 + tf->fontStyle().weight()) || | 273 200 + tf->fontStyle().weight()) || |
| 268 fontDescription.isSyntheticBold(), | 274 fontDescription.isSyntheticBold(), |
| 269 ((fontDescription.style() == FontStyleItalic || | 275 ((fontDescription.style() == FontStyleItalic || |
| 270 fontDescription.style() == FontStyleOblique) && | 276 fontDescription.style() == FontStyleOblique) && |
| 271 !tf->isItalic()) || | 277 !tf->isItalic()) || |
| 272 fontDescription.isSyntheticItalic(), | 278 fontDescription.isSyntheticItalic(), |
| 273 fontDescription.orientation())); | 279 fontDescription.orientation())); |
| 274 } | 280 } |
| 275 #endif // !OS(WIN) | 281 #endif // !OS(WIN) |
| 276 | 282 |
| 277 } // namespace blink | 283 } // namespace blink |
| OLD | NEW |