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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 int PlatformFontPango::GetBaseline() const { | 192 int PlatformFontPango::GetBaseline() const { |
193 return ascent_pixels_; | 193 return ascent_pixels_; |
194 } | 194 } |
195 | 195 |
196 int PlatformFontPango::GetAverageCharacterWidth() const { | 196 int PlatformFontPango::GetAverageCharacterWidth() const { |
197 const_cast<PlatformFontPango*>(this)->InitPangoMetrics(); | 197 const_cast<PlatformFontPango*>(this)->InitPangoMetrics(); |
198 return SkScalarRound(average_width_pixels_); | 198 return SkScalarRound(average_width_pixels_); |
199 } | 199 } |
200 | 200 |
201 int PlatformFontPango::GetStringWidth(const string16& text) const { | 201 int PlatformFontPango::GetStringWidth(const base::string16& text) const { |
202 return Canvas::GetStringWidth(text, | 202 return Canvas::GetStringWidth(text, |
203 Font(const_cast<PlatformFontPango*>(this))); | 203 Font(const_cast<PlatformFontPango*>(this))); |
204 } | 204 } |
205 | 205 |
206 int PlatformFontPango::GetExpectedTextWidth(int length) const { | 206 int PlatformFontPango::GetExpectedTextWidth(int length) const { |
207 double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth(); | 207 double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth(); |
208 return round(static_cast<float>(length) * char_width); | 208 return round(static_cast<float>(length) * char_width); |
209 } | 209 } |
210 | 210 |
211 int PlatformFontPango::GetStyle() const { | 211 int PlatformFontPango::GetStyle() const { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 return new PlatformFontPango(native_font); | 384 return new PlatformFontPango(native_font); |
385 } | 385 } |
386 | 386 |
387 // static | 387 // static |
388 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 388 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
389 int font_size) { | 389 int font_size) { |
390 return new PlatformFontPango(font_name, font_size); | 390 return new PlatformFontPango(font_name, font_size); |
391 } | 391 } |
392 | 392 |
393 } // namespace gfx | 393 } // namespace gfx |
OLD | NEW |