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

Unified Diff: ui/gfx/render_text.cc

Issue 738363002: Enable subpixel positioning for UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: std::round to std::floor(+0.5) Created 6 years 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 | « ui/gfx/font_render_params_win.cc ('k') | ui/gfx/render_text_harfbuzz.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 87e650b8cf3107637f407cad49850905f17fac68..add661d64c9d5edc34449ac3b0cf53bc7d102756 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -722,7 +722,9 @@ SizeF RenderText::GetStringSizeF() {
}
float RenderText::GetContentWidth() {
- return GetStringSizeF().width() + (cursor_enabled_ ? 1 : 0);
+ // The cursor is drawn one pixel beyond the int-enclosed text bounds.
+ return cursor_enabled_ ?
+ std::ceil(GetStringSizeF().width()) + 1 : GetStringSizeF().width();
}
int RenderText::GetBaseline() {
@@ -1071,7 +1073,7 @@ Vector2d RenderText::GetAlignmentOffset(size_t line_number) {
HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment();
if (horizontal_alignment != ALIGN_LEFT) {
#if defined(OS_WIN)
- const int width = lines_[line_number].size.width() +
+ const int width = std::ceil(lines_[line_number].size.width()) +
(cursor_enabled_ ? 1 : 0);
#else
const int width = GetContentWidth();
« no previous file with comments | « ui/gfx/font_render_params_win.cc ('k') | ui/gfx/render_text_harfbuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698