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 3c71cff58c57c1b5dabf7aacff9bf7cc9764be6e..f3dd136fcc8431e0ac4297c3416be753d5c789fa 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" |
| @@ -314,6 +315,7 @@ class HarfBuzzLineBreaker { |
| // Width from |std::max(word->first, start_char)| to the current character. |
| SkScalar word_width = 0; |
| *width = 0; |
| + std::set<size_t> used_glyphs; |
| for (size_t i = start_char; i < run.range.end(); ++i) { |
| // |word| holds the word boundary at or before |i|, and |next_word| holds |
| @@ -325,6 +327,19 @@ class HarfBuzzLineBreaker { |
| } |
| Range glyph_range = run.CharRangeToGlyphRange(Range(i, i + 1)); |
| + |
| + // Sometimes multiple code points can point to the same glyph (e.g. |
|
msw
2015/03/24 22:52:45
This fix seems odd/wrong. Shouldn't the line above
Jun Mukai
2015/03/25 00:23:15
This is inside of EnsureLayout(), which is called
|
| + // diacritic marks). We need to skip in that case to avoid adding |
| + // the width of the same glyph multiple times. |
| + bool already_used = false; |
| + for (size_t i = glyph_range.start(); i < glyph_range.end(); ++i) { |
| + if (used_glyphs.find(i) != used_glyphs.end()) |
| + already_used = true; |
| + used_glyphs.insert(i); |
| + } |
| + if (already_used) |
| + continue; |
| + |
| SkScalar char_width = ((glyph_range.end() >= run.glyph_count) |
| ? SkFloatToScalar(run.width) |
| : run.positions[glyph_range.end()].x()) - |