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

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 1036663003: Break runs by clusters rather than iteration over code points (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) -
« 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