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

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

Issue 1037863002: Remove the code which sorts and removes duplicates from the fallback font list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include <set>
8 9
9 #include "base/i18n/bidi_line_iterator.h" 10 #include "base/i18n/bidi_line_iterator.h"
10 #include "base/i18n/break_iterator.h" 11 #include "base/i18n/break_iterator.h"
11 #include "base/i18n/char_iterator.h" 12 #include "base/i18n/char_iterator.h"
12 #include "base/profiler/scoped_tracker.h" 13 #include "base/profiler/scoped_tracker.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
16 #include "third_party/harfbuzz-ng/src/hb.h" 17 #include "third_party/harfbuzz-ng/src/hb.h"
17 #include "third_party/icu/source/common/unicode/ubidi.h" 18 #include "third_party/icu/source/common/unicode/ubidi.h"
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 // fallback font list. 1300 // fallback font list.
1300 if (!LowerCaseEqualsASCII(primary_family, "segoe ui") && 1301 if (!LowerCaseEqualsASCII(primary_family, "segoe ui") &&
1301 !LowerCaseEqualsASCII(uniscribe_family, "segoe ui")) { 1302 !LowerCaseEqualsASCII(uniscribe_family, "segoe ui")) {
1302 std::vector<std::string> default_fallback_families = 1303 std::vector<std::string> default_fallback_families =
1303 GetFallbackFontFamilies("Segoe UI"); 1304 GetFallbackFontFamilies("Segoe UI");
1304 fallback_families.insert(fallback_families.end(), 1305 fallback_families.insert(fallback_families.end(),
1305 default_fallback_families.begin(), default_fallback_families.end()); 1306 default_fallback_families.begin(), default_fallback_families.end());
1306 } 1307 }
1307 #endif 1308 #endif
1308 1309
1309 // Get rid of duplicate fonts in the fallback list. We use the std::unique 1310 // The fallback font list could contain duplicate fonts. To avoid processing
msw 2015/03/25 22:55:29 nit: "// Use a set to track the fallback fonts and
ananta 2015/03/25 23:19:48 Done.
1310 // algorithm for this. However for this function to work we need to sort 1311 // them again, we use a set to track if a fallback font has been seen and
1311 // the font list as the unique algorithm relies on duplicates being adjacent. 1312 // skip it if yes.
1312 // TODO(ananta) 1313 std::set<std::string> duplicate_fallback_font_tracker;
1313 // Sorting the list changes the order in which fonts are evaluated. This may
1314 // cause problems in the way some characters appear. It may be best to do
1315 // font fallback on the same lines as blink or skia which do this based on
1316 // character glyph mapping.
1317 std::sort(fallback_families.begin(), fallback_families.end());
1318 fallback_families.erase(std::unique(
1319 fallback_families.begin(), fallback_families.end()),
1320 fallback_families.end());
1321 1314
1322 // Try shaping with the fallback fonts. 1315 // Try shaping with the fallback fonts.
1323 for (const auto& family : fallback_families) { 1316 for (const auto& family : fallback_families) {
1324 if (family == primary_family) 1317 if (family == primary_family)
1325 continue; 1318 continue;
1326 #if defined(OS_WIN) 1319 #if defined(OS_WIN)
1327 if (family == uniscribe_family) 1320 if (family == uniscribe_family)
1328 continue; 1321 continue;
1329 #endif 1322 #endif
1323 if (duplicate_fallback_font_tracker.find(family) !=
msw 2015/03/25 22:55:29 nit: should this use LowerCaseEqualsASCII?
ananta 2015/03/25 23:19:48 Passed a case insensitive comparison operator to t
1324 duplicate_fallback_font_tracker.end())
1325 continue;
1326
1327 duplicate_fallback_font_tracker.insert(family);
1328
1330 FontRenderParamsQuery query(false); 1329 FontRenderParamsQuery query(false);
1331 query.families.push_back(family); 1330 query.families.push_back(family);
1332 query.pixel_size = run->font_size; 1331 query.pixel_size = run->font_size;
1333 query.style = run->font_style; 1332 query.style = run->font_style;
1334 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL); 1333 FontRenderParams fallback_render_params = GetFontRenderParams(query, NULL);
1335 if (CompareFamily(text, family, fallback_render_params, run, &best_family, 1334 if (CompareFamily(text, family, fallback_render_params, run, &best_family,
1336 &best_render_params, &best_missing_glyphs)) 1335 &best_render_params, &best_missing_glyphs))
1337 return; 1336 return;
1338 } 1337 }
1339 1338
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 DCHECK(!update_layout_run_list_); 1518 DCHECK(!update_layout_run_list_);
1520 DCHECK(!update_display_run_list_); 1519 DCHECK(!update_display_run_list_);
1521 return text_elided() ? display_run_list_.get() : &layout_run_list_; 1520 return text_elided() ? display_run_list_.get() : &layout_run_list_;
1522 } 1521 }
1523 1522
1524 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { 1523 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const {
1525 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); 1524 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList();
1526 } 1525 }
1527 1526
1528 } // namespace gfx 1527 } // 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