| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 AtomicString ToAtomicString(const SkString& str) { | 67 AtomicString ToAtomicString(const SkString& str) { |
| 68 return AtomicString::FromUTF8(str.c_str(), str.size()); | 68 return AtomicString::FromUTF8(str.c_str(), str.size()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 #if OS(ANDROID) || OS(LINUX) | 71 #if OS(ANDROID) || OS(LINUX) |
| 72 // Android special locale for retrieving the color emoji font | 72 // Android special locale for retrieving the color emoji font |
| 73 // based on the proposed changes in UTR #51 for introducing | 73 // based on the proposed changes in UTR #51 for introducing |
| 74 // an Emoji script code: | 74 // an Emoji script code: |
| 75 // http://www.unicode.org/reports/tr51/proposed.html#Emoji_Script | 75 // http://www.unicode.org/reports/tr51/proposed.html#Emoji_Script |
| 76 static const char* g_k_android_color_emoji_locale = "und-Zsye"; | 76 static const char kAndroidColorEmojiLocale[] = "und-Zsye"; |
| 77 | 77 |
| 78 // This function is called on android or when we are emulating android fonts on | 78 // This function is called on android or when we are emulating android fonts on |
| 79 // linux and the embedder has overriden the default fontManager with | 79 // linux and the embedder has overriden the default fontManager with |
| 80 // WebFontRendering::setSkiaFontMgr. | 80 // WebFontRendering::setSkiaFontMgr. |
| 81 // static | 81 // static |
| 82 AtomicString FontCache::GetFamilyNameForCharacter( | 82 AtomicString FontCache::GetFamilyNameForCharacter( |
| 83 SkFontMgr* fm, | 83 SkFontMgr* fm, |
| 84 UChar32 c, | 84 UChar32 c, |
| 85 const FontDescription& font_description, | 85 const FontDescription& font_description, |
| 86 FontFallbackPriority fallback_priority) { | 86 FontFallbackPriority fallback_priority) { |
| 87 ASSERT(fm); | 87 ASSERT(fm); |
| 88 | 88 |
| 89 const size_t kMaxLocales = 4; | 89 const size_t kMaxLocales = 4; |
| 90 const char* bcp47_locales[kMaxLocales]; | 90 const char* bcp47_locales[kMaxLocales]; |
| 91 size_t locale_count = 0; | 91 size_t locale_count = 0; |
| 92 | 92 |
| 93 // Fill in the list of locales in the reverse priority order. | 93 // Fill in the list of locales in the reverse priority order. |
| 94 // Skia expects the highest array index to be the first priority. | 94 // Skia expects the highest array index to be the first priority. |
| 95 const LayoutLocale* content_locale = font_description.Locale(); | 95 const LayoutLocale* content_locale = font_description.Locale(); |
| 96 if (const LayoutLocale* han_locale = | 96 if (const LayoutLocale* han_locale = |
| 97 LayoutLocale::LocaleForHan(content_locale)) | 97 LayoutLocale::LocaleForHan(content_locale)) |
| 98 bcp47_locales[locale_count++] = han_locale->LocaleForHanForSkFontMgr(); | 98 bcp47_locales[locale_count++] = han_locale->LocaleForHanForSkFontMgr(); |
| 99 bcp47_locales[locale_count++] = | 99 bcp47_locales[locale_count++] = |
| 100 LayoutLocale::GetDefault().LocaleForSkFontMgr(); | 100 LayoutLocale::GetDefault().LocaleForSkFontMgr(); |
| 101 if (content_locale) | 101 if (content_locale) |
| 102 bcp47_locales[locale_count++] = content_locale->LocaleForSkFontMgr(); | 102 bcp47_locales[locale_count++] = content_locale->LocaleForSkFontMgr(); |
| 103 if (fallback_priority == FontFallbackPriority::kEmojiEmoji) | 103 if (fallback_priority == FontFallbackPriority::kEmojiEmoji) |
| 104 bcp47_locales[locale_count++] = g_k_android_color_emoji_locale; | 104 bcp47_locales[locale_count++] = kAndroidColorEmojiLocale; |
| 105 SECURITY_DCHECK(locale_count <= kMaxLocales); | 105 SECURITY_DCHECK(locale_count <= kMaxLocales); |
| 106 sk_sp<SkTypeface> typeface(fm->matchFamilyStyleCharacter( | 106 sk_sp<SkTypeface> typeface(fm->matchFamilyStyleCharacter( |
| 107 0, SkFontStyle(), bcp47_locales, locale_count, c)); | 107 0, SkFontStyle(), bcp47_locales, locale_count, c)); |
| 108 if (!typeface) | 108 if (!typeface) |
| 109 return g_empty_atom; | 109 return g_empty_atom; |
| 110 | 110 |
| 111 SkString skia_family_name; | 111 SkString skia_family_name; |
| 112 typeface->getFamilyName(&skia_family_name); | 112 typeface->getFamilyName(&skia_family_name); |
| 113 return ToAtomicString(skia_family_name); | 113 return ToAtomicString(skia_family_name); |
| 114 } | 114 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 font_description.IsSyntheticBold(), | 285 font_description.IsSyntheticBold(), |
| 286 ((font_description.Style() == kFontStyleItalic || | 286 ((font_description.Style() == kFontStyleItalic || |
| 287 font_description.Style() == kFontStyleOblique) && | 287 font_description.Style() == kFontStyleOblique) && |
| 288 !tf->isItalic()) || | 288 !tf->isItalic()) || |
| 289 font_description.IsSyntheticItalic(), | 289 font_description.IsSyntheticItalic(), |
| 290 font_description.Orientation())); | 290 font_description.Orientation())); |
| 291 } | 291 } |
| 292 #endif // !OS(WIN) | 292 #endif // !OS(WIN) |
| 293 | 293 |
| 294 } // namespace blink | 294 } // namespace blink |
| OLD | NEW |