| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 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::GetAverageCharacterWidth() const { | 185 float PlatformFontPango::GetAverageCharacterWidth() const { |
| 186 const_cast<PlatformFontPango*>(this)->InitPangoMetrics(); | 186 const_cast<PlatformFontPango*>(this)->InitPangoMetrics(); |
| 187 return SkScalarRound(average_width_pixels_); | 187 return SkScalarRound(average_width_pixels_); |
| 188 } | 188 } |
| 189 | 189 |
| 190 int PlatformFontPango::GetStringWidth(const base::string16& text) const { | 190 float PlatformFontPango::GetStringWidth(const base::string16& text) const { |
| 191 return Canvas::GetStringWidth(text, | 191 return Canvas::GetStringWidth(text, |
| 192 Font(const_cast<PlatformFontPango*>(this))); | 192 Font(const_cast<PlatformFontPango*>(this))); |
| 193 } | 193 } |
| 194 | 194 |
| 195 int PlatformFontPango::GetExpectedTextWidth(int length) const { | 195 float PlatformFontPango::GetExpectedTextWidth(int length) const { |
| 196 double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth(); | 196 double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth(); |
| 197 return round(static_cast<float>(length) * char_width); | 197 return round(static_cast<float>(length) * char_width); |
| 198 } | 198 } |
| 199 | 199 |
| 200 int PlatformFontPango::GetStyle() const { | 200 int PlatformFontPango::GetStyle() const { |
| 201 return style_; | 201 return style_; |
| 202 } | 202 } |
| 203 | 203 |
| 204 std::string PlatformFontPango::GetFontName() const { | 204 std::string PlatformFontPango::GetFontName() const { |
| 205 return font_family_; | 205 return font_family_; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 return new PlatformFontPango(native_font); | 400 return new PlatformFontPango(native_font); |
| 401 } | 401 } |
| 402 | 402 |
| 403 // static | 403 // static |
| 404 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 404 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
| 405 int font_size) { | 405 int font_size) { |
| 406 return new PlatformFontPango(font_name, font_size); | 406 return new PlatformFontPango(font_name, font_size); |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace gfx | 409 } // namespace gfx |
| OLD | NEW |