| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 namespace blink { | 64 namespace blink { |
| 65 | 65 |
| 66 #if OS(ANDROID) || OS(LINUX) | 66 #if OS(ANDROID) || OS(LINUX) |
| 67 // Android special locale for retrieving the color emoji font | 67 // Android special locale for retrieving the color emoji font |
| 68 // based on the proposed changes in UTR #51 for introducing | 68 // based on the proposed changes in UTR #51 for introducing |
| 69 // an Emoji script code: | 69 // an Emoji script code: |
| 70 // http://www.unicode.org/reports/tr51/proposed.html#Emoji_Script | 70 // http://www.unicode.org/reports/tr51/proposed.html#Emoji_Script |
| 71 static const char* kAndroidColorEmojiLocale = "und-Zsye"; | 71 static const char* kAndroidColorEmojiLocale = "und-Zsye"; |
| 72 | 72 |
| 73 // This function is called on android or when we are emulating android fonts on
linux and the | 73 // This function is called on android or when we are emulating android fonts on |
| 74 // embedder has overriden the default fontManager with WebFontRendering::setSkia
FontMgr. | 74 // linux and the embedder has overriden the default fontManager with |
| 75 // WebFontRendering::setSkiaFontMgr. |
| 75 // static | 76 // static |
| 76 AtomicString FontCache::getFamilyNameForCharacter( | 77 AtomicString FontCache::getFamilyNameForCharacter( |
| 77 SkFontMgr* fm, | 78 SkFontMgr* fm, |
| 78 UChar32 c, | 79 UChar32 c, |
| 79 const FontDescription& fontDescription, | 80 const FontDescription& fontDescription, |
| 80 FontFallbackPriority fallbackPriority) { | 81 FontFallbackPriority fallbackPriority) { |
| 81 ASSERT(fm); | 82 ASSERT(fm); |
| 82 | 83 |
| 83 const size_t kMaxLocales = 4; | 84 const size_t kMaxLocales = 4; |
| 84 const char* bcp47Locales[kMaxLocales]; | 85 const char* bcp47Locales[kMaxLocales]; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 134 } |
| 134 | 135 |
| 135 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont( | 136 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont( |
| 136 const FontDescription& description, | 137 const FontDescription& description, |
| 137 ShouldRetain shouldRetain) { | 138 ShouldRetain shouldRetain) { |
| 138 const FontFaceCreationParams fallbackCreationParams( | 139 const FontFaceCreationParams fallbackCreationParams( |
| 139 getFallbackFontFamily(description)); | 140 getFallbackFontFamily(description)); |
| 140 const FontPlatformData* fontPlatformData = | 141 const FontPlatformData* fontPlatformData = |
| 141 getFontPlatformData(description, fallbackCreationParams); | 142 getFontPlatformData(description, fallbackCreationParams); |
| 142 | 143 |
| 143 // We should at least have Sans or Arial which is the last resort fallback of
SkFontHost ports. | 144 // We should at least have Sans or Arial which is the last resort fallback of |
| 145 // SkFontHost ports. |
| 144 if (!fontPlatformData) { | 146 if (!fontPlatformData) { |
| 145 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, sansCreationParams, | 147 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, sansCreationParams, |
| 146 (AtomicString("Sans"))); | 148 (AtomicString("Sans"))); |
| 147 fontPlatformData = getFontPlatformData(description, sansCreationParams); | 149 fontPlatformData = getFontPlatformData(description, sansCreationParams); |
| 148 } | 150 } |
| 149 if (!fontPlatformData) { | 151 if (!fontPlatformData) { |
| 150 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, arialCreationParams, | 152 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, arialCreationParams, |
| 151 (AtomicString("Arial"))); | 153 (AtomicString("Arial"))); |
| 152 fontPlatformData = getFontPlatformData(description, arialCreationParams); | 154 fontPlatformData = getFontPlatformData(description, arialCreationParams); |
| 153 } | 155 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) { | 204 if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) { |
| 203 if (Platform::current()->sandboxSupport()) | 205 if (Platform::current()->sandboxSupport()) |
| 204 return typefaceForFontconfigInterfaceIdAndTtcIndex( | 206 return typefaceForFontconfigInterfaceIdAndTtcIndex( |
| 205 creationParams.fontconfigInterfaceId(), creationParams.ttcIndex()); | 207 creationParams.fontconfigInterfaceId(), creationParams.ttcIndex()); |
| 206 return SkTypeface::MakeFromFile(creationParams.filename().data(), | 208 return SkTypeface::MakeFromFile(creationParams.filename().data(), |
| 207 creationParams.ttcIndex()); | 209 creationParams.ttcIndex()); |
| 208 } | 210 } |
| 209 #endif | 211 #endif |
| 210 | 212 |
| 211 AtomicString family = creationParams.family(); | 213 AtomicString family = creationParams.family(); |
| 212 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the n
ame into | 214 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the |
| 213 // the fallback name (like "monospace") that fontconfig understands. | 215 // name into the fallback name (like "monospace") that fontconfig understands. |
| 214 if (!family.length() || family.startsWith("-webkit-")) { | 216 if (!family.length() || family.startsWith("-webkit-")) { |
| 215 name = getFallbackFontFamily(fontDescription).getString().utf8(); | 217 name = getFallbackFontFamily(fontDescription).getString().utf8(); |
| 216 } else { | 218 } else { |
| 217 // convert the name to utf8 | 219 // convert the name to utf8 |
| 218 name = family.utf8(); | 220 name = family.utf8(); |
| 219 } | 221 } |
| 220 | 222 |
| 221 #if OS(WIN) | 223 #if OS(WIN) |
| 222 if (s_sideloadedFonts) { | 224 if (s_sideloadedFonts) { |
| 223 HashMap<String, sk_sp<SkTypeface>>::iterator sideloadedFont = | 225 HashMap<String, sk_sp<SkTypeface>>::iterator sideloadedFont = |
| 224 s_sideloadedFonts->find(name.data()); | 226 s_sideloadedFonts->find(name.data()); |
| 225 if (sideloadedFont != s_sideloadedFonts->end()) | 227 if (sideloadedFont != s_sideloadedFonts->end()) |
| 226 return sideloadedFont->value; | 228 return sideloadedFont->value; |
| 227 } | 229 } |
| 228 #endif | 230 #endif |
| 229 | 231 |
| 230 #if OS(LINUX) || OS(WIN) | 232 #if OS(LINUX) || OS(WIN) |
| 231 // On linux if the fontManager has been overridden then we should be calling t
he embedder | 233 // On linux if the fontManager has been overridden then we should be calling |
| 232 // provided font Manager rather than calling SkTypeface::CreateFromName which
may redirect the | 234 // the embedder provided font Manager rather than calling |
| 233 // call to the default font Manager. | 235 // SkTypeface::CreateFromName which may redirect the call to the default font |
| 234 // On Windows the font manager is always present. | 236 // Manager. On Windows the font manager is always present. |
| 235 if (m_fontManager) | 237 if (m_fontManager) |
| 236 return sk_sp<SkTypeface>(m_fontManager->matchFamilyStyle( | 238 return sk_sp<SkTypeface>(m_fontManager->matchFamilyStyle( |
| 237 name.data(), fontDescription.skiaFontStyle())); | 239 name.data(), fontDescription.skiaFontStyle())); |
| 238 #endif | 240 #endif |
| 239 | 241 |
| 240 // FIXME: Use m_fontManager, matchFamilyStyle instead of | 242 // FIXME: Use m_fontManager, matchFamilyStyle instead of |
| 241 // legacyCreateTypeface on all platforms. | 243 // legacyCreateTypeface on all platforms. |
| 242 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 244 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 243 return sk_sp<SkTypeface>( | 245 return sk_sp<SkTypeface>( |
| 244 fm->legacyCreateTypeface(name.data(), fontDescription.skiaFontStyle())); | 246 fm->legacyCreateTypeface(name.data(), fontDescription.skiaFontStyle())); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 260 fontDescription.isSyntheticBold(), | 262 fontDescription.isSyntheticBold(), |
| 261 ((fontDescription.style() == FontStyleItalic || | 263 ((fontDescription.style() == FontStyleItalic || |
| 262 fontDescription.style() == FontStyleOblique) && | 264 fontDescription.style() == FontStyleOblique) && |
| 263 !tf->isItalic()) || | 265 !tf->isItalic()) || |
| 264 fontDescription.isSyntheticItalic(), | 266 fontDescription.isSyntheticItalic(), |
| 265 fontDescription.orientation())); | 267 fontDescription.orientation())); |
| 266 } | 268 } |
| 267 #endif // !OS(WIN) | 269 #endif // !OS(WIN) |
| 268 | 270 |
| 269 } // namespace blink | 271 } // namespace blink |
| OLD | NEW |