Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp

Issue 2192703002: More LayoutLocale refactor with additional Chinese support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment updated as per drott review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "SkFontMgr.h" 31 #include "SkFontMgr.h"
32 #include "SkStream.h" 32 #include "SkStream.h"
33 #include "SkTypeface.h" 33 #include "SkTypeface.h"
34 #include "platform/Language.h" 34 #include "platform/Language.h"
35 #include "platform/fonts/AcceptLanguagesResolver.h"
36 #include "platform/fonts/AlternateFontFamily.h" 35 #include "platform/fonts/AlternateFontFamily.h"
37 #include "platform/fonts/FontCache.h" 36 #include "platform/fonts/FontCache.h"
38 #include "platform/fonts/FontDescription.h" 37 #include "platform/fonts/FontDescription.h"
39 #include "platform/fonts/FontFaceCreationParams.h" 38 #include "platform/fonts/FontFaceCreationParams.h"
40 #include "platform/fonts/SimpleFontData.h" 39 #include "platform/fonts/SimpleFontData.h"
41 #include "platform/graphics/skia/SkiaUtils.h" 40 #include "platform/graphics/skia/SkiaUtils.h"
42 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
43 #include "public/platform/linux/WebSandboxSupport.h" 42 #include "public/platform/linux/WebSandboxSupport.h"
44 #include "wtf/Assertions.h" 43 #include "wtf/Assertions.h"
45 #include "wtf/PtrUtil.h" 44 #include "wtf/PtrUtil.h"
(...skipping 28 matching lines...) Expand all
74 // embedder has overriden the default fontManager with WebFontRendering::setSkia FontMgr. 73 // embedder has overriden the default fontManager with WebFontRendering::setSkia FontMgr.
75 // static 74 // static
76 AtomicString FontCache::getFamilyNameForCharacter(SkFontMgr* fm, UChar32 c, cons t FontDescription& fontDescription, FontFallbackPriority fallbackPriority) 75 AtomicString FontCache::getFamilyNameForCharacter(SkFontMgr* fm, UChar32 c, cons t FontDescription& fontDescription, FontFallbackPriority fallbackPriority)
77 { 76 {
78 ASSERT(fm); 77 ASSERT(fm);
79 78
80 const size_t kMaxLocales = 4; 79 const size_t kMaxLocales = 4;
81 const char* bcp47Locales[kMaxLocales]; 80 const char* bcp47Locales[kMaxLocales];
82 size_t localeCount = 0; 81 size_t localeCount = 0;
83 82
84 if (fallbackPriority == FontFallbackPriority::EmojiEmoji) { 83 // Fill in the list of locales in the reverse priority order.
84 // Skia expects the highest array index to be the first priority.
85 const LayoutLocale* contentLocale = fontDescription.locale();
86 if (const LayoutLocale* hanLocale = LayoutLocale::localeForHan(contentLocale ))
87 bcp47Locales[localeCount++] = hanLocale->localeForHanForSkFontMgr();
88 bcp47Locales[localeCount++] = LayoutLocale::getDefault().localeForSkFontMgr( );
89 if (contentLocale)
90 bcp47Locales[localeCount++] = contentLocale->localeForSkFontMgr();
91 if (fallbackPriority == FontFallbackPriority::EmojiEmoji)
85 bcp47Locales[localeCount++] = kAndroidColorEmojiLocale; 92 bcp47Locales[localeCount++] = kAndroidColorEmojiLocale;
86 }
87 if (const char* hanLocale = AcceptLanguagesResolver::preferredHanSkFontMgrLo cale())
88 bcp47Locales[localeCount++] = hanLocale;
89 bcp47Locales[localeCount++] = LayoutLocale::getDefault().localeForSkFontMgr( ).data();
90 if (const LayoutLocale* locale = fontDescription.locale())
91 bcp47Locales[localeCount++] = locale->localeForSkFontMgr().data();
92 ASSERT_WITH_SECURITY_IMPLICATION(localeCount < kMaxLocales); 93 ASSERT_WITH_SECURITY_IMPLICATION(localeCount < kMaxLocales);
93 RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFo ntStyle(), bcp47Locales, localeCount, c)); 94 RefPtr<SkTypeface> typeface = adoptRef(fm->matchFamilyStyleCharacter(0, SkFo ntStyle(), bcp47Locales, localeCount, c));
94 if (!typeface) 95 if (!typeface)
95 return emptyAtom; 96 return emptyAtom;
96 97
97 SkString skiaFamilyName; 98 SkString skiaFamilyName;
98 typeface->getFamilyName(&skiaFamilyName); 99 typeface->getFamilyName(&skiaFamilyName);
99 return skiaFamilyName.c_str(); 100 return skiaFamilyName.c_str();
100 } 101 }
101 #endif 102 #endif
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return wrapUnique(new FontPlatformData(tf, 211 return wrapUnique(new FontPlatformData(tf,
211 name.data(), 212 name.data(),
212 fontSize, 213 fontSize,
213 (fontDescription.weight() > 200 + tf->fontStyle().weight()) || fontDescr iption.isSyntheticBold(), 214 (fontDescription.weight() > 200 + tf->fontStyle().weight()) || fontDescr iption.isSyntheticBold(),
214 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), 215 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(),
215 fontDescription.orientation())); 216 fontDescription.orientation()));
216 } 217 }
217 #endif // !OS(WIN) 218 #endif // !OS(WIN)
218 219
219 } // namespace blink 220 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698