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

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

Issue 185863007: Try last resort on no-match in platformFallbackForCharacter on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Unit test Created 6 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 | « Source/platform/fonts/android/FontCacheAndroidTest.cpp ('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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 FontPlatformData* substitutePlatformData = getFontPlatformData(description, atomicFamily); 80 FontPlatformData* substitutePlatformData = getFontPlatformData(description, atomicFamily);
81 if (!substitutePlatformData) 81 if (!substitutePlatformData)
82 return nullptr; 82 return nullptr;
83 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); 83 FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
84 platformData.setSyntheticBold(shouldSetSyntheticBold); 84 platformData.setSyntheticBold(shouldSetSyntheticBold);
85 platformData.setSyntheticItalic(shouldSetSyntheticItalic); 85 platformData.setSyntheticItalic(shouldSetSyntheticItalic);
86 return fontDataFromFontPlatformData(&platformData, DoNotRetain); 86 return fontDataFromFontPlatformData(&platformData, DoNotRetain);
87 } 87 }
88 88
89 #endif // !OS(WINDOWNS) && !OS(ANDROID) 89 #endif // !OS(WIN) && !OS(ANDROID)
90 90
91 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri ption& description, ShouldRetain shouldRetain) 91 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri ption& description, ShouldRetain shouldRetain)
92 { 92 {
93 const AtomicString fallbackFontFamily = getFallbackFontFamily(description); 93 const AtomicString fallbackFontFamily = getFallbackFontFamily(description);
94 const FontPlatformData* fontPlatformData = 0; 94 const FontPlatformData* fontPlatformData = 0;
95 if (!fallbackFontFamily.isEmpty()) 95 if (!fallbackFontFamily.isEmpty())
96 fontPlatformData = getFontPlatformData(description, fallbackFontFamily); 96 fontPlatformData = getFontPlatformData(description, fallbackFontFamily);
97 97
98 if (!fontPlatformData) { 98 if (!fontPlatformData) {
99 // we should at least have Arial; this is the SkFontHost_fontconfig last resort fallback 99 // we should at least have Arial; this is the SkFontHost_fontconfig last resort fallback
100 DEFINE_STATIC_LOCAL(const AtomicString, arialStr, ("Arial", AtomicString ::ConstructFromLiteral)); 100 DEFINE_STATIC_LOCAL(const AtomicString, arialStr, ("Arial", AtomicString ::ConstructFromLiteral));
101 fontPlatformData = getFontPlatformData(description, arialStr); 101 fontPlatformData = getFontPlatformData(description, arialStr);
102 } 102 }
103 103
104 ASSERT(fontPlatformData); 104 ASSERT(fontPlatformData);
105 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); 105 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
106 } 106 }
107 107
108 PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc ription, const AtomicString& family, CString& name) 108 PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc ription, const AtomicString& family, CString& name)
109 { 109 {
110 name = "";
111
112 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into 110 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
113 // the fallback name (like "monospace") that fontconfig understands. 111 // the fallback name (like "monospace") that fontconfig understands.
114 if (!family.length() || family.startsWith("-webkit-")) { 112 if (!family.length() || family.startsWith("-webkit-")) {
115 static const struct { 113 name = getFallbackFontFamily(fontDescription).string().utf8();
116 FontDescription::GenericFamilyType mType;
117 const char* mName;
118 } fontDescriptions[] = {
119 { FontDescription::SerifFamily, "serif" },
120 { FontDescription::SansSerifFamily, "sans-serif" },
121 { FontDescription::MonospaceFamily, "monospace" },
122 { FontDescription::CursiveFamily, "cursive" },
123 { FontDescription::FantasyFamily, "fantasy" }
124 };
125
126 FontDescription::GenericFamilyType type = fontDescription.genericFamily( );
127 for (unsigned i = 0; i < SK_ARRAY_COUNT(fontDescriptions); i++) {
128 if (type == fontDescriptions[i].mType) {
129 name = fontDescriptions[i].mName;
130 break;
131 }
132 }
133 } else { 114 } else {
134 // convert the name to utf8 115 // convert the name to utf8
135 name = family.utf8(); 116 name = family.utf8();
136 } 117 }
137 118
138 int style = SkTypeface::kNormal; 119 int style = SkTypeface::kNormal;
139 if (fontDescription.weight() >= FontWeightBold) 120 if (fontDescription.weight() >= FontWeightBold)
140 style |= SkTypeface::kBold; 121 style |= SkTypeface::kBold;
141 if (fontDescription.italic()) 122 if (fontDescription.italic())
142 style |= SkTypeface::kItalic; 123 style |= SkTypeface::kItalic;
(...skipping 17 matching lines...) Expand all
160 141
161 FontPlatformData* result = new FontPlatformData(tf, 142 FontPlatformData* result = new FontPlatformData(tf,
162 name.data(), 143 name.data(),
163 fontSize, 144 fontSize,
164 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes cription.isSyntheticBold(), 145 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes cription.isSyntheticBold(),
165 (fontDescription.italic() && !tf->isItalic()) || fontDescription.isSynth eticItalic(), 146 (fontDescription.italic() && !tf->isItalic()) || fontDescription.isSynth eticItalic(),
166 fontDescription.orientation(), 147 fontDescription.orientation(),
167 fontDescription.useSubpixelPositioning()); 148 fontDescription.useSubpixelPositioning());
168 return result; 149 return result;
169 } 150 }
170 #endif // !OS(WINDOWNS) 151 #endif // !OS(WIN)
171 152
172 } // namespace WebCore 153 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/fonts/android/FontCacheAndroidTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698