Chromium Code Reviews| Index: ui/gfx/render_text_win.cc |
| =================================================================== |
| --- ui/gfx/render_text_win.cc (revision 134923) |
| +++ ui/gfx/render_text_win.cc (working copy) |
| @@ -653,6 +653,23 @@ |
| glyphs_missing = true; |
| break; |
| } |
| + |
| + // On Vista, when trying to draw Simplified Chinese via font linking, |
|
msw
2012/05/02 22:19:09
Perhaps generalize this comment if there may be ot
Alexei Svitkine (slow)
2012/05/03 14:37:20
Done.
|
| + // missing glyphs in the Meiryo font are returned as wgBlank instead |
| + // of wgDefault, with fZeroWidth set. |
| + if (run->glyphs[i] == properties.wgBlank && |
| + run->visible_attributes[i].fZeroWidth) { |
| + // Check whether this glyph corresponds entirely to whitespace. If |
| + // it doesn't, assume there are missing glyphs. |
| + const ui::Range range = GetTextRangeForRunGlyph(run, i); |
| + DCHECK_NE(0U, range.length()); |
|
msw
2012/05/02 22:19:09
Use DCHECK_GT? Also DCHECK_LT/LE(range.end(), run-
|
| + |
| + const string16 glyph_text(&run_text[range.start()], range.length()); |
| + if (!ContainsOnlyWhitespace(glyph_text)) { |
| + glyphs_missing = true; |
| + break; |
| + } |
| + } |
| } |
| } |
| @@ -804,17 +821,32 @@ |
| } |
| SelectionModel RenderTextWin::FirstSelectionModelInsideRun( |
| - internal::TextRun* run) { |
| + const internal::TextRun* run) { |
| size_t cursor = IndexOfAdjacentGrapheme(run->range.start(), CURSOR_FORWARD); |
| return SelectionModel(cursor, CURSOR_BACKWARD); |
| } |
| SelectionModel RenderTextWin::LastSelectionModelInsideRun( |
| - internal::TextRun* run) { |
| + const internal::TextRun* run) { |
| size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); |
| return SelectionModel(caret, CURSOR_FORWARD); |
| } |
| +ui::Range RenderTextWin::GetTextRangeForRunGlyph(const internal::TextRun* run, |
| + size_t glyph_index) const { |
| + int first_seen = -1; |
| + int last_seen = -1; |
| + for (size_t char_index = 0; char_index < run->range.length(); ++char_index) { |
| + if (run->logical_clusters[char_index] == glyph_index) { |
| + last_seen = char_index; |
| + if (first_seen == -1) |
| + first_seen = char_index; |
| + } |
| + } |
| + DCHECK_NE(first_seen, -1); |
| + return ui::Range(first_seen, last_seen + 1); |
| +} |
| + |
| RenderText* RenderText::CreateRenderText() { |
| return new RenderTextWin; |
| } |