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

Unified Diff: ui/gfx/render_text_win.cc

Issue 8401032: Correct text y position calculation in RenderTextWin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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_win.cc
===================================================================
--- ui/gfx/render_text_win.cc (revision 107565)
+++ ui/gfx/render_text_win.cc (working copy)
@@ -589,8 +589,13 @@
Point offset(ToViewPoint(Point()));
// TODO(msw): Establish a vertical baseline for strings of mixed font heights.
size_t height = default_style().font.GetHeight();
+
+ float base_x = SkIntToScalar(offset.x());
+ float base_y = SkIntToScalar(offset.y());
// Center the text vertically in the display area.
- offset.Offset(0, (display_rect().height() - height) / 2);
+ base_y += (display_rect().height() - default_style().font.GetHeight()) / 2;
msw 2011/10/27 18:09:29 You have an extra space after the minus symbol '-'
+ // Offset by the font size to account for Skia expecting y to be the bottom.
+ base_y += default_style().font.GetFontSize();
SkPaint paint;
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
@@ -598,8 +603,7 @@
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setLCDRenderText(true);
- SkPoint point(SkPoint::Make(SkIntToScalar(offset.x()),
- SkIntToScalar(display_rect().height() - offset.y())));
+
scoped_array<SkPoint> pos;
for (size_t i = 0; i < runs_.size(); ++i) {
// Get the run specified by the visual-to-logical map.
@@ -620,9 +624,9 @@
// Based on WebCore::skiaDrawText.
pos.reset(new SkPoint[run->glyph_count]);
for (int glyph = 0; glyph < run->glyph_count; glyph++) {
- pos[glyph].set(point.x() + run->offsets[glyph].du,
- point.y() + run->offsets[glyph].dv);
- point.offset(SkIntToScalar(run->advance_widths[glyph]), 0);
+ pos[glyph].set(base_x + run->offsets[glyph].du,
+ base_y + run->offsets[glyph].dv);
+ base_x += SkIntToScalar(run->advance_widths[glyph]);
}
size_t byte_length = run->glyph_count * sizeof(WORD);
canvas_skia->drawPosText(run->glyphs.get(), byte_length, pos.get(), paint);
« 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