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

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: GetClusterAt() 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 | ui/gfx/render_text_unittest.cc » ('j') | ui/gfx/render_text_unittest.cc » ('J')
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..ae3717a5cf6ee59c876ec637d68496c82672fc4d 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>
msw 2015/03/25 20:25:16 nit: remove
Jun Mukai 2015/03/25 21:50:05 Done.
#include "base/i18n/bidi_line_iterator.h"
#include "base/i18n/break_iterator.h"
@@ -298,7 +299,6 @@ class HarfBuzzLineBreaker {
// |*next_char| will be greater than |start_char| (to avoid constructing empty
// lines).
// Returns whether to skip the line before |*next_char|.
- // TODO(ckocagil): Check clusters to avoid breaking ligatures and diacritics.
// TODO(ckocagil): We might have to reshape after breaking at ligatures.
// See whether resolving the TODO above resolves this too.
// TODO(ckocagil): Do not reserve width for whitespace at the end of lines.
@@ -315,7 +315,8 @@ class HarfBuzzLineBreaker {
SkScalar word_width = 0;
*width = 0;
- for (size_t i = start_char; i < run.range.end(); ++i) {
+ Range char_range;
+ for (size_t i = start_char; i < run.range.end(); i += char_range.length()) {
// |word| holds the word boundary at or before |i|, and |next_word| holds
// the word boundary right after |i|. Advance both |word| and |next_word|
// when |i| reaches |next_word|.
@@ -324,7 +325,10 @@ class HarfBuzzLineBreaker {
word_width = 0;
}
- Range glyph_range = run.CharRangeToGlyphRange(Range(i, i + 1));
+ Range glyph_range;
+ run.GetClusterAt(i, &char_range, &glyph_range);
+ DCHECK_LT(0U, char_range.length());
+
SkScalar char_width = ((glyph_range.end() >= run.glyph_count)
? SkFloatToScalar(run.width)
: run.positions[glyph_range.end()].x()) -
@@ -344,7 +348,7 @@ class HarfBuzzLineBreaker {
*next_char = i;
} else {
// Continue from the next character.
- *next_char = i + 1;
+ *next_char = i + char_range.length();
}
return true;
}
« no previous file with comments | « no previous file | ui/gfx/render_text_unittest.cc » ('j') | ui/gfx/render_text_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698