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

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 300623003: Fix the Char to Glyph mapping logic in RenderTextHarfBuzz (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 10e7a1a5276931a44ad6e8ff6643d5a03bba9ed9..43432f9c60956a5619745eacf9860044fd677a5a 100644
--- a/ui/gfx/render_text_harfbuzz.cc
+++ b/ui/gfx/render_text_harfbuzz.cc
@@ -359,16 +359,25 @@ size_t TextRunHarfBuzz::CharToGlyph(size_t pos) const {
return 0;
}
-Range TextRunHarfBuzz::CharRangeToGlyphRange(const Range& range) const {
- DCHECK(range.Contains(range));
- DCHECK(!range.is_reversed());
- DCHECK(!range.is_empty());
-
- const size_t first = CharToGlyph(range.start());
- const size_t last = CharToGlyph(range.end() - 1);
- // TODO(ckocagil): What happens when the character has zero or multiple
- // glyphs? Is the "+ 1" below correct then?
- return Range(std::min(first, last), std::max(first, last) + 1);
+Range TextRunHarfBuzz::CharRangeToGlyphRange(const Range& char_range) const {
+ DCHECK(range.Contains(char_range));
+ DCHECK(!char_range.is_reversed());
+ DCHECK(!char_range.is_empty());
+
+ size_t first = 0;
+ size_t last = 0;
+
+ if (direction == UBIDI_RTL) {
+ // For RTL runs, we subtract 1 from |char_range| to get the trailing edges.
msw 2014/05/28 01:18:30 nit: the meaning of "to get the trailing edges" is
ckocagil 2014/06/02 02:57:42 I tried to find a better way to explain this, but
msw 2014/06/02 19:37:58 So a char range of [1,2) would yield "[c)ba" witho
ckocagil 2014/06/03 22:25:17 What I mean by trailing is: imagine if CharToGlyph
+ first = char_range.start() == range.start() ?
+ glyph_count : CharToGlyph(char_range.start() - 1);
+ last = CharToGlyph(char_range.end() - 1);
+ } else {
+ first = CharToGlyph(char_range.start());
+ last = char_range.end() == range.end() ?
+ glyph_count : CharToGlyph(char_range.end());
msw 2014/05/28 00:52:33 This doesn't seem right. It seems like if the end
ckocagil 2014/05/28 01:02:02 |char_range.end() == range.end()| doesn't mean "la
msw 2014/05/28 01:18:30 Ah, that makes more way more sense.
+ }
+ return Range(std::min(first, last), std::max(first, last));
}
// Returns whether the given shaped run contains any missing glyphs.
« 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