| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/platform_font_gtk.h" | 5 #include "gfx/platform_font_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
| 9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 int PlatformFontGtk::GetBaseline() const { | 214 int PlatformFontGtk::GetBaseline() const { |
| 215 return ascent_; | 215 return ascent_; |
| 216 } | 216 } |
| 217 | 217 |
| 218 int PlatformFontGtk::GetAverageCharacterWidth() const { | 218 int PlatformFontGtk::GetAverageCharacterWidth() const { |
| 219 return SkScalarRound(average_width_); | 219 return SkScalarRound(average_width_); |
| 220 } | 220 } |
| 221 | 221 |
| 222 int PlatformFontGtk::GetStringWidth(const std::wstring& text) const { | 222 int PlatformFontGtk::GetStringWidth(const std::wstring& text) const { |
| 223 int width = 0, height = 0; | 223 int width = 0, height = 0; |
| 224 CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontGtk*>(this)), | 224 CanvasSkia::SizeStringInt(WideToUTF16Hack(text), |
| 225 Font(const_cast<PlatformFontGtk*>(this)), |
| 225 &width, &height, gfx::Canvas::NO_ELLIPSIS); | 226 &width, &height, gfx::Canvas::NO_ELLIPSIS); |
| 226 return width; | 227 return width; |
| 227 } | 228 } |
| 228 | 229 |
| 229 int PlatformFontGtk::GetExpectedTextWidth(int length) const { | 230 int PlatformFontGtk::GetExpectedTextWidth(int length) const { |
| 230 double char_width = const_cast<PlatformFontGtk*>(this)->GetAverageWidth(); | 231 double char_width = const_cast<PlatformFontGtk*>(this)->GetAverageWidth(); |
| 231 return round(static_cast<float>(length) * char_width); | 232 return round(static_cast<float>(length) * char_width); |
| 232 } | 233 } |
| 233 | 234 |
| 234 int PlatformFontGtk::GetStyle() const { | 235 int PlatformFontGtk::GetStyle() const { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 return new PlatformFontGtk(native_font); | 435 return new PlatformFontGtk(native_font); |
| 435 } | 436 } |
| 436 | 437 |
| 437 // static | 438 // static |
| 438 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name, | 439 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::wstring& font_name, |
| 439 int font_size) { | 440 int font_size) { |
| 440 return new PlatformFontGtk(font_name, font_size); | 441 return new PlatformFontGtk(font_name, font_size); |
| 441 } | 442 } |
| 442 | 443 |
| 443 } // namespace gfx | 444 } // namespace gfx |
| OLD | NEW |