| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |