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

Side by Side Diff: ui/gfx/platform_font_pango.cc

Issue 25039002: Always aligns text at vertically center (Textfield, Label). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/font_unittest.cc ('k') | ui/gfx/render_text.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/platform_font_pango.h" 5 #include "ui/gfx/platform_font_pango.h"
6 6
7 #include <fontconfig/fontconfig.h> 7 #include <fontconfig/fontconfig.h>
8 #include <pango/pango.h> 8 #include <pango/pango.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 int PlatformFontPango::GetHeight() const { 177 int PlatformFontPango::GetHeight() const {
178 return height_pixels_; 178 return height_pixels_;
179 } 179 }
180 180
181 int PlatformFontPango::GetBaseline() const { 181 int PlatformFontPango::GetBaseline() const {
182 return ascent_pixels_; 182 return ascent_pixels_;
183 } 183 }
184 184
185 int PlatformFontPango::GetCapHeight() const { 185 int PlatformFontPango::GetCapHeight() const {
186 // Return the height as an approximation because Pango doesn't support cap 186 // Return the ascent as an approximation because Pango doesn't support cap
187 // height. 187 // height.
188 // TODO(yukishiino): Come up with a better approximation of cap height, or 188 // TODO(yukishiino): Come up with a better approximation of cap height, or
189 // support cap height metrics. Another option is to have a hard-coded table 189 // support cap height metrics. Another option is to have a hard-coded table
190 // of cap height for major fonts used in Chromium/Chrome. 190 // of cap height for major fonts used in Chromium/Chrome.
191 // See http://crbug.com/249507 191 // See http://crbug.com/249507
192 return height_pixels_; 192 return ascent_pixels_;
193 } 193 }
194 194
195 int PlatformFontPango::GetAverageCharacterWidth() const { 195 int PlatformFontPango::GetAverageCharacterWidth() const {
196 const_cast<PlatformFontPango*>(this)->InitPangoMetrics(); 196 const_cast<PlatformFontPango*>(this)->InitPangoMetrics();
197 return SkScalarRound(average_width_pixels_); 197 return SkScalarRound(average_width_pixels_);
198 } 198 }
199 199
200 int PlatformFontPango::GetStringWidth(const base::string16& text) const { 200 int PlatformFontPango::GetStringWidth(const base::string16& text) const {
201 return Canvas::GetStringWidth(text, 201 return Canvas::GetStringWidth(text,
202 Font(const_cast<PlatformFontPango*>(this))); 202 Font(const_cast<PlatformFontPango*>(this)));
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 return new PlatformFontPango(native_font); 409 return new PlatformFontPango(native_font);
410 } 410 }
411 411
412 // static 412 // static
413 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 413 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
414 int font_size) { 414 int font_size) {
415 return new PlatformFontPango(font_name, font_size); 415 return new PlatformFontPango(font_name, font_size);
416 } 416 }
417 417
418 } // namespace gfx 418 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_unittest.cc ('k') | ui/gfx/render_text.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698