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

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

Issue 1750213003: Revert of Add FontCache API for retrieving prioritized fallback fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 25 matching lines...) Expand all
36 #include "platform/fonts/FontDescription.h" 36 #include "platform/fonts/FontDescription.h"
37 #include "platform/fonts/FontFaceCreationParams.h" 37 #include "platform/fonts/FontFaceCreationParams.h"
38 #include "platform/fonts/SimpleFontData.h" 38 #include "platform/fonts/SimpleFontData.h"
39 #include "public/platform/Platform.h" 39 #include "public/platform/Platform.h"
40 #include "public/platform/linux/WebSandboxSupport.h" 40 #include "public/platform/linux/WebSandboxSupport.h"
41 #include "wtf/Assertions.h" 41 #include "wtf/Assertions.h"
42 #include "wtf/text/AtomicString.h" 42 #include "wtf/text/AtomicString.h"
43 #include "wtf/text/CString.h" 43 #include "wtf/text/CString.h"
44 #include <unicode/locid.h> 44 #include <unicode/locid.h>
45 45
46 // Unfortunately, these chosen font names require a bit of experimentation and
47 // researching on the respective platforms as to what works best and is widely
48 // available. They may require further manual tuning. Mozilla's choices in the
49 // gfxPlatform*::GetCommonFallbackFonts methods collects some of the outcome of
50 // this experimentation. On Android, the available fonts in
51 // /system/etc/fonts.xml give a clearer picture of which fonts are available and
52 // can be widely used successfully. On Linux, updating and improving this list
53 // requires finding out widely used distribution fonts, for example on current
54 // Ubuntu versions.
55 #if OS(WIN)
56 const char* kColorEmojiFonts[] = { "Segoe UI Emoji", "Segoe UI Symbol" };
57 const char* kTextEmojiFonts[] = { "Segoe UI Symbol", "Code2000", "Lucida Sans Un icode" };
58 const char* kSymbolsFonts[] = { "Segoe UI Symbol", "Code2000", "Lucida Sans Unic ode" };
59 const char* kMathFonts[] = { "Cambria Math", "Segoe UI Symbol", "Code2000" };
60 #elif OS(ANDROID)
61 // Due to crbug.com/322658 we cannot properly specify Android font family names here,
62 // The way Skia's SkFontMgr_android gives them canonical names, we can however
63 // reference the Noto Color Emoji font under "56##fallback" on Android 6.0.1
64 const char* kColorEmojiFonts[] = { "56##fallback", "Noto Color Emoji", "Android Emoji" };
65 const char* kTextEmojiFonts[] = { "Droid Sans Fallback" };
66 const char* kSymbolsFonts[] = { "Droid Sans Fallback" };
67 const char* kMathFonts[] = { "Droid Sans Fallback" };
68 #elif OS(LINUX)
69 const char* kColorEmojiFonts[] = { "Noto Color Emoji", "Noto Sans Symbols", "Sym bola", "DejaVu Sans" };
70 const char* kTextEmojiFonts[] = { "Noto Sans Symbols", "Symbola", "Droid Sans Fa llback", "DejaVu Sans" };
71 const char* kSymbolsFonts[] = { "FreeSerif", "FreeMono", "Droid Sans Fallback", "DejaVu Sans" };
72 const char* kMathFonts[] = { "FreeSerif", "FreeMono", "Droid Sans Fallback", "De jaVu Sans" };
73 #endif
74
75 #if !OS(WIN) && !OS(ANDROID) 46 #if !OS(WIN) && !OS(ANDROID)
76 #include "SkFontConfigInterface.h" 47 #include "SkFontConfigInterface.h"
77 48
78 static PassRefPtr<SkTypeface> typefaceForFontconfigInterfaceIdAndTtcIndex(int fo ntconfigInterfaceId, int ttcIndex) 49 static PassRefPtr<SkTypeface> typefaceForFontconfigInterfaceIdAndTtcIndex(int fo ntconfigInterfaceId, int ttcIndex)
79 { 50 {
80 SkAutoTUnref<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal()); 51 SkAutoTUnref<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal());
81 SkFontConfigInterface::FontIdentity fontIdentity; 52 SkFontConfigInterface::FontIdentity fontIdentity;
82 fontIdentity.fID = fontconfigInterfaceId; 53 fontIdentity.fID = fontconfigInterfaceId;
83 fontIdentity.fTTCIndex = ttcIndex; 54 fontIdentity.fTTCIndex = ttcIndex;
84 return adoptRef(fci->createTypeface(fontIdentity)); 55 return adoptRef(fci->createTypeface(fontIdentity));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (!fontPlatformData) { 154 if (!fontPlatformData) {
184 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationPar ams, (AtomicString("Microsoft Sans Serif", AtomicString::ConstructFromLiteral))) ; 155 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationPar ams, (AtomicString("Microsoft Sans Serif", AtomicString::ConstructFromLiteral))) ;
185 fontPlatformData = getFontPlatformData(description, mssansserifCreationP arams); 156 fontPlatformData = getFontPlatformData(description, mssansserifCreationP arams);
186 } 157 }
187 #endif 158 #endif
188 159
189 ASSERT(fontPlatformData); 160 ASSERT(fontPlatformData);
190 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); 161 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
191 } 162 }
192 163
193 const Vector<AtomicString> FontCache::platformFontListForFallbackPriority(FontFa llbackPriority fallbackPriority) const
194 {
195 Vector<AtomicString> returnVector;
196 switch (fallbackPriority) {
197 case FontFallbackPriority::EmojiEmoji:
198 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kColorEmojiFonts); ++i)
199 returnVector.append(kColorEmojiFonts[i]);
200 break;
201 case FontFallbackPriority::EmojiText:
202 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kTextEmojiFonts); ++i)
203 returnVector.append(kTextEmojiFonts[i]);
204 break;
205 case FontFallbackPriority::Math:
206 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kMathFonts); ++i)
207 returnVector.append(kMathFonts[i]);
208 break;
209 case FontFallbackPriority::Symbols:
210 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kSymbolsFonts); ++i)
211 returnVector.append(kSymbolsFonts[i]);
212 break;
213 default:
214 ASSERT_NOT_REACHED();
215 }
216 return returnVector;
217 }
218
219 #if OS(WIN) 164 #if OS(WIN)
220 static inline SkFontStyle fontStyle(const FontDescription& fontDescription) 165 static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
221 { 166 {
222 int width = static_cast<int>(fontDescription.stretch()); 167 int width = static_cast<int>(fontDescription.stretch());
223 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100; 168 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100;
224 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic 169 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic
225 ? SkFontStyle::kItalic_Slant 170 ? SkFontStyle::kItalic_Slant
226 : SkFontStyle::kUpright_Slant; 171 : SkFontStyle::kUpright_Slant;
227 return SkFontStyle(weight, width, slant); 172 return SkFontStyle(weight, width, slant);
228 } 173 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 name.data(), 240 name.data(),
296 fontSize, 241 fontSize,
297 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), 242 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(),
298 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), 243 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(),
299 fontDescription.orientation(), 244 fontDescription.orientation(),
300 fontDescription.useSubpixelPositioning())); 245 fontDescription.useSubpixelPositioning()));
301 } 246 }
302 #endif // !OS(WIN) 247 #endif // !OS(WIN)
303 248
304 } // namespace blink 249 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698