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 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. |