| 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..314ed65f15e203ed1c5433de4fb211bf600969bc 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"
|
| @@ -467,6 +468,13 @@ class HarfBuzzLineBreaker {
|
| DISALLOW_COPY_AND_ASSIGN(HarfBuzzLineBreaker);
|
| };
|
|
|
| +// Function object for case insensitive string comparison.
|
| +struct CaseInsensitiveCompare {
|
| + bool operator() (const std::string& a, const std::string& b) const {
|
| + return base::strncasecmp(a.c_str(), b.c_str(), b.length()) < 0;
|
| + }
|
| +};
|
| +
|
| } // namespace
|
|
|
| namespace internal {
|
| @@ -1306,18 +1314,8 @@ 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());
|
| + // Use a set to track the fallback fonts and avoid duplicate entries.
|
| + std::set<std::string, CaseInsensitiveCompare> fallback_fonts;
|
|
|
| // Try shaping with the fallback fonts.
|
| for (const auto& family : fallback_families) {
|
| @@ -1327,6 +1325,11 @@ void RenderTextHarfBuzz::ShapeRun(const base::string16& text,
|
| if (family == uniscribe_family)
|
| continue;
|
| #endif
|
| + if (fallback_fonts.find(family) != fallback_fonts.end())
|
| + continue;
|
| +
|
| + fallback_fonts.insert(family);
|
| +
|
| FontRenderParamsQuery query(false);
|
| query.families.push_back(family);
|
| query.pixel_size = run->font_size;
|
|
|