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

Unified Diff: ui/gfx/render_text_win.cc

Issue 19734003: Fixes vertical alignment of RenderTextWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc
index 05be785e4a53921c4225a43554f869377b445544..ea3e3e9925fd4d634588a8608ae0eafe5bbd66b0 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -488,8 +488,8 @@ void RenderTextWin::DrawVisualText(Canvas* canvas) {
void RenderTextWin::ItemizeLogicalText() {
runs_.clear();
- string_size_ = Size(0, GetFont().GetHeight());
- common_baseline_ = 0;
+ string_size_ = Size(0, font_list().GetHeight());
+ common_baseline_ = font_list().GetBaseline();
Alexei Svitkine (slow) 2013/07/24 15:29:48 This value will be clobbered unless the text is em
Yuki 2013/07/25 14:32:41 Done.
// Set Uniscribe's base text direction.
script_state_.uBidiLevel =
@@ -564,14 +564,15 @@ void RenderTextWin::LayoutVisualText() {
cached_hdc_ = CreateCompatibleDC(NULL);
HRESULT hr = E_FAIL;
- string_size_.set_height(0);
+ int ascent = font_list().GetBaseline();
+ int descent = font_list().GetHeight() - font_list().GetBaseline();
Alexei Svitkine (slow) 2013/07/24 15:29:48 I'm not sure it makes sense to start with the metr
msw 2013/07/24 18:02:36 Using just the fonts of the runs and not including
Alexei Svitkine (slow) 2013/07/24 18:12:28 Ah, I understand now. Thanks for the explanation -
Yuki 2013/07/25 14:32:41 Done.
for (size_t i = 0; i < runs_.size(); ++i) {
internal::TextRun* run = runs_[i];
LayoutTextRun(run);
- string_size_.set_height(std::max(string_size_.height(),
- run->font.GetHeight()));
- common_baseline_ = std::max(common_baseline_, run->font.GetBaseline());
+ ascent = std::max(ascent, run->font.GetBaseline());
+ descent = std::max(descent,
+ run->font.GetHeight() - run->font.GetBaseline());
if (run->glyph_count > 0) {
run->advance_widths.reset(new int[run->glyph_count]);
@@ -588,6 +589,8 @@ void RenderTextWin::LayoutVisualText() {
DCHECK(SUCCEEDED(hr));
}
}
+ string_size_.set_height(ascent + descent);
+ common_baseline_ = ascent;
// Build the array of bidirectional embedding levels.
scoped_ptr<BYTE[]> levels(new BYTE[runs_.size()]);
« 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