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

Side by Side Diff: ui/gfx/render_text_harfbuzz.cc

Issue 1019743004: Remove duplicate fonts from the font fallback list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments Created 5 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 | « no previous file | 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_harfbuzz.h" 5 #include "ui/gfx/render_text_harfbuzz.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/i18n/bidi_line_iterator.h" 9 #include "base/i18n/bidi_line_iterator.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 // ensure that the fallback list covers the basic cases. 1295 // ensure that the fallback list covers the basic cases.
1296 // http://crbug.com/467459. On some Windows configurations the default font 1296 // http://crbug.com/467459. On some Windows configurations the default font
1297 // could be a raster font like System, which would not give us a reasonable 1297 // could be a raster font like System, which would not give us a reasonable
1298 // fallback font list. 1298 // fallback font list.
1299 std::vector<std::string> default_fallback_families = 1299 std::vector<std::string> default_fallback_families =
1300 GetFallbackFontFamilies("Segoe UI"); 1300 GetFallbackFontFamilies("Segoe UI");
1301 fallback_families.insert(fallback_families.end(), 1301 fallback_families.insert(fallback_families.end(),
1302 default_fallback_families.begin(), default_fallback_families.end()); 1302 default_fallback_families.begin(), default_fallback_families.end());
1303 #endif 1303 #endif
1304 1304
1305 // Get rid of duplicate fonts in the fallback list. We use the std::unique
1306 // algorithm for this. However for this function to work we need to sort
1307 // the font list as the unique algorithm relies on duplicates being adjacent.
1308 // TODO(ananta)
1309 // Sorting the list changes the order in which fonts are evaluated. This may
1310 // cause problems in the way some characters appear. It may be best to do
1311 // font fallback on the same lines as blink or skia which do this based on
1312 // character glyph mapping.
1313 std::sort(fallback_families.begin(), fallback_families.end());
1314 fallback_families.erase(std::unique(
1315 fallback_families.begin(), fallback_families.end()),
1316 fallback_families.end());
1317
1305 // Try shaping with the fallback fonts. 1318 // Try shaping with the fallback fonts.
1306 for (const auto& family : fallback_families) { 1319 for (const auto& family : fallback_families) {
1307 if (family == primary_family) 1320 if (family == primary_family)
1308 continue; 1321 continue;
1309 #if defined(OS_WIN) 1322 #if defined(OS_WIN)
1310 if (family == uniscribe_family) 1323 if (family == uniscribe_family)
1311 continue; 1324 continue;
1312 #endif 1325 #endif
1313 FontRenderParamsQuery query(false); 1326 FontRenderParamsQuery query(false);
1314 query.families.push_back(family); 1327 query.families.push_back(family);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 DCHECK(!update_layout_run_list_); 1515 DCHECK(!update_layout_run_list_);
1503 DCHECK(!update_display_run_list_); 1516 DCHECK(!update_display_run_list_);
1504 return text_elided() ? display_run_list_.get() : &layout_run_list_; 1517 return text_elided() ? display_run_list_.get() : &layout_run_list_;
1505 } 1518 }
1506 1519
1507 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { 1520 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const {
1508 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); 1521 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList();
1509 } 1522 }
1510 1523
1511 } // namespace gfx 1524 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698