Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 if (!fontPlatformData) { | 147 if (!fontPlatformData) { |
| 148 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationPar ams, (AtomicString("Microsoft Sans Serif"))); | 148 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationPar ams, (AtomicString("Microsoft Sans Serif"))); |
| 149 fontPlatformData = getFontPlatformData(description, mssansserifCreationP arams); | 149 fontPlatformData = getFontPlatformData(description, mssansserifCreationP arams); |
| 150 } | 150 } |
| 151 #endif | 151 #endif |
| 152 | 152 |
| 153 ASSERT(fontPlatformData); | 153 ASSERT(fontPlatformData); |
| 154 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); | 154 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); |
| 155 } | 155 } |
| 156 | 156 |
| 157 static inline SkFontStyle fontStyle(const FontDescription& fontDescription) | |
|
bungeman-skia
2016/04/25 14:58:00
Looks like this moved over to FontDescription::ski
Tom (Use chromium acct)
2016/04/25 19:02:21
Done.
| |
| 158 { | |
| 159 int width = static_cast<int>(fontDescription.stretch()); | |
| 160 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100; | |
| 161 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic | |
| 162 ? SkFontStyle::kItalic_Slant | |
| 163 : SkFontStyle::kUpright_Slant; | |
| 164 return SkFontStyle(weight, width, slant); | |
| 165 } | |
| 166 | |
| 167 static_assert(static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(Sk FontStyle::kUltraCondensed_Width), | |
| 168 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); | |
| 169 static_assert(static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyl e::kNormal_Width), | |
| 170 "FontStretchNormal should map to kNormal_Width"); | |
| 171 static_assert(static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkF ontStyle::kUltaExpanded_Width), | |
| 172 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); | |
| 173 | |
| 157 PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc ription, const FontFaceCreationParams& creationParams, CString& name) | 174 PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc ription, const FontFaceCreationParams& creationParams, CString& name) |
| 158 { | 175 { |
| 159 #if !OS(WIN) && !OS(ANDROID) | 176 #if !OS(WIN) && !OS(ANDROID) |
| 160 if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) { | 177 if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) { |
| 161 if (Platform::current()->sandboxSupport()) | 178 if (Platform::current()->sandboxSupport()) |
| 162 return typefaceForFontconfigInterfaceIdAndTtcIndex(creationParams.fo ntconfigInterfaceId(), creationParams.ttcIndex()); | 179 return typefaceForFontconfigInterfaceIdAndTtcIndex(creationParams.fo ntconfigInterfaceId(), creationParams.ttcIndex()); |
| 163 return adoptRef(SkTypeface::CreateFromFile(creationParams.filename().dat a(), creationParams.ttcIndex())); | 180 return adoptRef(SkTypeface::CreateFromFile(creationParams.filename().dat a(), creationParams.ttcIndex())); |
| 164 } | 181 } |
| 165 #endif | 182 #endif |
| 166 | 183 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 190 #endif | 207 #endif |
| 191 | 208 |
| 192 #if OS(LINUX) | 209 #if OS(LINUX) |
| 193 // On linux if the fontManager has been overridden then we should be calling the embedder | 210 // On linux if the fontManager has been overridden then we should be calling the embedder |
| 194 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the | 211 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the |
| 195 // call to the default font Manager. | 212 // call to the default font Manager. |
| 196 if (m_fontManager) | 213 if (m_fontManager) |
| 197 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescrip tion.skiaFontStyle())); | 214 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescrip tion.skiaFontStyle())); |
| 198 #endif | 215 #endif |
| 199 | 216 |
| 200 // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of | 217 // FIXME: Use m_fontManager, matchFamilyStyle instead of |
| 201 // CreateFromName on all platforms. | 218 // legacyCreateTypeface on all platforms. |
| 202 int style = SkTypeface::kNormal; | 219 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); |
| 203 if (fontDescription.weight() >= FontWeight600) | 220 return adoptRef(fm->legacyCreateTypeface(name.data(), |
| 204 style |= SkTypeface::kBold; | 221 fontStyle(fontDescription))); |
|
bungeman-skia
2016/04/25 14:58:00
fontDescription.skiaFontStyle() instead of fontSty
Tom (Use chromium acct)
2016/04/25 19:02:21
Done.
| |
| 205 if (fontDescription.style()) | |
| 206 style |= SkTypeface::kItalic; | |
| 207 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style))); | |
| 208 } | 222 } |
| 209 | 223 |
| 210 #if !OS(WIN) | 224 #if !OS(WIN) |
| 211 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, | 225 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, |
| 212 const FontFaceCreationParams& creationParams, float fontSize) | 226 const FontFaceCreationParams& creationParams, float fontSize) |
| 213 { | 227 { |
| 214 CString name; | 228 CString name; |
| 215 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; | 229 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; |
| 216 if (!tf) | 230 if (!tf) |
| 217 return nullptr; | 231 return nullptr; |
| 218 | 232 |
| 219 return adoptPtr(new FontPlatformData(tf, | 233 return adoptPtr(new FontPlatformData(tf, |
| 220 name.data(), | 234 name.data(), |
| 221 fontSize, | 235 fontSize, |
| 222 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), | 236 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), |
|
bungeman-skia
2016/04/25 14:58:01
So what appears to happening on on Android is that
Tom (Use chromium acct)
2016/04/25 19:02:21
Done.
| |
| 223 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), | 237 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), |
| 224 fontDescription.orientation(), | 238 fontDescription.orientation(), |
| 225 fontDescription.useSubpixelPositioning())); | 239 fontDescription.useSubpixelPositioning())); |
| 226 } | 240 } |
| 227 #endif // !OS(WIN) | 241 #endif // !OS(WIN) |
| 228 | 242 |
| 229 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |