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

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

Issue 2441343003: Allow the default generic font family settings to find the first available font (Closed)
Patch Set: msw review Created 4 years, 1 month 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 "platform/fonts/GenericFontFamilySettings.h" 31 #include "platform/fonts/GenericFontFamilySettings.h"
32 32
33 #include "platform/fonts/FontCache.h"
34
33 namespace blink { 35 namespace blink {
34 36
35 GenericFontFamilySettings::GenericFontFamilySettings( 37 GenericFontFamilySettings::GenericFontFamilySettings(
36 const GenericFontFamilySettings& other) 38 const GenericFontFamilySettings& other)
37 : m_standardFontFamilyMap(other.m_standardFontFamilyMap), 39 : m_standardFontFamilyMap(other.m_standardFontFamilyMap),
38 m_serifFontFamilyMap(other.m_serifFontFamilyMap), 40 m_serifFontFamilyMap(other.m_serifFontFamilyMap),
39 m_fixedFontFamilyMap(other.m_fixedFontFamilyMap), 41 m_fixedFontFamilyMap(other.m_fixedFontFamilyMap),
40 m_sansSerifFontFamilyMap(other.m_sansSerifFontFamilyMap), 42 m_sansSerifFontFamilyMap(other.m_sansSerifFontFamilyMap),
41 m_cursiveFontFamilyMap(other.m_cursiveFontFamilyMap), 43 m_cursiveFontFamilyMap(other.m_cursiveFontFamilyMap),
42 m_fantasyFontFamilyMap(other.m_fantasyFontFamilyMap), 44 m_fantasyFontFamilyMap(other.m_fantasyFontFamilyMap),
(...skipping 25 matching lines...) Expand all
68 } else if (it != fontMap.end() && it->value == family) { 70 } else if (it != fontMap.end() && it->value == family) {
69 return; 71 return;
70 } else { 72 } else {
71 fontMap.set(static_cast<int>(script), family); 73 fontMap.set(static_cast<int>(script), family);
72 } 74 }
73 } 75 }
74 76
75 const AtomicString& GenericFontFamilySettings::genericFontFamilyForScript( 77 const AtomicString& GenericFontFamilySettings::genericFontFamilyForScript(
76 const ScriptFontFamilyMap& fontMap, 78 const ScriptFontFamilyMap& fontMap,
77 UScriptCode script) const { 79 UScriptCode script) const {
78 ScriptFontFamilyMap::const_iterator it = 80 ScriptFontFamilyMap::iterator it =
79 fontMap.find(static_cast<int>(script)); 81 const_cast<ScriptFontFamilyMap&>(fontMap).find(static_cast<int>(script));
80 if (it != fontMap.end()) 82 if (it != fontMap.end()) {
83 // Replace with the first available font if it starts with ",".
84 if (!it->value.isEmpty() && it->value[0] == ',')
85 it->value = AtomicString(FontCache::firstAvailableOrFirst(it->value));
81 return it->value; 86 return it->value;
87 }
82 if (script != USCRIPT_COMMON) 88 if (script != USCRIPT_COMMON)
83 return genericFontFamilyForScript(fontMap, USCRIPT_COMMON); 89 return genericFontFamilyForScript(fontMap, USCRIPT_COMMON);
84 return emptyAtom; 90 return emptyAtom;
85 } 91 }
86 92
87 const AtomicString& GenericFontFamilySettings::standard( 93 const AtomicString& GenericFontFamilySettings::standard(
88 UScriptCode script) const { 94 UScriptCode script) const {
89 return genericFontFamilyForScript(m_standardFontFamilyMap, script); 95 return genericFontFamilyForScript(m_standardFontFamilyMap, script);
90 } 96 }
91 97
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 m_standardFontFamilyMap.clear(); 183 m_standardFontFamilyMap.clear();
178 m_serifFontFamilyMap.clear(); 184 m_serifFontFamilyMap.clear();
179 m_fixedFontFamilyMap.clear(); 185 m_fixedFontFamilyMap.clear();
180 m_sansSerifFontFamilyMap.clear(); 186 m_sansSerifFontFamilyMap.clear();
181 m_cursiveFontFamilyMap.clear(); 187 m_cursiveFontFamilyMap.clear();
182 m_fantasyFontFamilyMap.clear(); 188 m_fantasyFontFamilyMap.clear();
183 m_pictographFontFamilyMap.clear(); 189 m_pictographFontFamilyMap.clear();
184 } 190 }
185 191
186 } // namespace blink 192 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698