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

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: win/mac test fix 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') | 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 63b0e4e0cd79d009e83cb9989e680f987def1e06..7314d13825cf8627d51dae5bf577db00650d8945 100644
--- a/ui/gfx/render_text_harfbuzz.cc
+++ b/ui/gfx/render_text_harfbuzz.cc
@@ -299,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.
@@ -316,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|.
@@ -325,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()) -
@@ -345,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698