Chromium Code Reviews| Index: ui/gfx/render_text_harfbuzz.cc |
| diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc |
| index 63b0e4e0cd79d009e83cb9989e680f987def1e06..2ad26893c810f7006963c11f10786e6576aac4e3 100644 |
| --- a/ui/gfx/render_text_harfbuzz.cc |
| +++ b/ui/gfx/render_text_harfbuzz.cc |
| @@ -5,6 +5,7 @@ |
| #include "ui/gfx/render_text_harfbuzz.h" |
| #include <limits> |
| +#include <set> |
| #include "base/i18n/bidi_line_iterator.h" |
| #include "base/i18n/break_iterator.h" |
| @@ -1306,18 +1307,10 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text, |
| } |
| #endif |
| - // Get rid of duplicate fonts in the fallback list. We use the std::unique |
| - // algorithm for this. However for this function to work we need to sort |
| - // the font list as the unique algorithm relies on duplicates being adjacent. |
| - // TODO(ananta) |
| - // Sorting the list changes the order in which fonts are evaluated. This may |
| - // cause problems in the way some characters appear. It may be best to do |
| - // font fallback on the same lines as blink or skia which do this based on |
| - // character glyph mapping. |
| - std::sort(fallback_families.begin(), fallback_families.end()); |
| - fallback_families.erase(std::unique( |
| - fallback_families.begin(), fallback_families.end()), |
| - fallback_families.end()); |
| + // 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.
|
| + // them again, we use a set to track if a fallback font has been seen and |
| + // skip it if yes. |
| + std::set<std::string> duplicate_fallback_font_tracker; |
| // Try shaping with the fallback fonts. |
| for (const auto& family : fallback_families) { |
| @@ -1327,6 +1320,12 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text, |
| if (family == uniscribe_family) |
| continue; |
| #endif |
| + 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
|
| + duplicate_fallback_font_tracker.end()) |
| + continue; |
| + |
| + duplicate_fallback_font_tracker.insert(family); |
| + |
| FontRenderParamsQuery query(false); |
| query.families.push_back(family); |
| query.pixel_size = run->font_size; |