Chromium Code Reviews| Index: ui/gfx/platform_font_gtk.cc |
| diff --git a/ui/gfx/platform_font_gtk.cc b/ui/gfx/platform_font_gtk.cc |
| index 5ccc7c53b3b80ee3048432d138595847ffee0afe..e1229daefa983952f1b137755a99bf638351559b 100644 |
| --- a/ui/gfx/platform_font_gtk.cc |
| +++ b/ui/gfx/platform_font_gtk.cc |
| @@ -6,20 +6,25 @@ |
| #include <algorithm> |
| #include <fontconfig/fontconfig.h> |
| -#include <gdk/gdk.h> |
| -#include <gtk/gtk.h> |
| #include <map> |
| #include <pango/pango.h> |
| +#include <string> |
| #include "base/logging.h" |
| #include "base/string_piece.h" |
| #include "base/utf_string_conversions.h" |
| +#include "pango/pangocairo.h" |
| #include "third_party/skia/include/core/SkTypeface.h" |
| #include "third_party/skia/include/core/SkPaint.h" |
| #include "ui/gfx/canvas_skia.h" |
| #include "ui/gfx/font.h" |
| #include "ui/gfx/gtk_util.h" |
| +#if !defined(USE_WAYLAND) |
| +#include <gdk/gdk.h> |
| +#include <gtk/gtk.h> |
| +#endif |
| + |
| namespace { |
| // The font family name which is used when a user's application font for |
| @@ -56,7 +61,7 @@ PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc) { |
| static PangoContext* context = NULL; |
| if (!context) { |
| - context = gdk_pango_context_get_for_screen(gdk_screen_get_default()); |
| + context = gfx::GetPangoContext(); |
| pango_context_set_language(context, pango_language_get_default()); |
| } |
| @@ -109,6 +114,26 @@ string16 FindBestMatchFontFamilyName(const char* family_name) { |
| return font_family; |
| } |
| +std::string GetDefaultFont() { |
| + std::string default_font("sans 10"); |
|
sky
2011/07/27 22:22:22
simplify this to:
#if defined(WAYLAND)
return "s
|
| + |
| +#if !defined(USE_WAYLAND) |
| + GtkSettings* settings = gtk_settings_get_default(); |
| + |
| + gchar* font_name = NULL; |
| + g_object_get(settings, "gtk-font-name", &font_name, NULL); |
| + |
| + // Temporary CHECK for helping track down |
| + // http://code.google.com/p/chromium/issues/detail?id=12530 |
| + CHECK(font_name) << " Unable to get gtk-font-name for default font."; |
| + |
| + default_font = std::string(font_name); |
| + g_free(font_name); |
| +#endif |
| + |
| + return default_font; |
| +} |
| + |
| } // namespace |
| namespace gfx { |
| @@ -120,20 +145,12 @@ Font* PlatformFontGtk::default_font_ = NULL; |
| PlatformFontGtk::PlatformFontGtk() { |
| if (default_font_ == NULL) { |
| - GtkSettings* settings = gtk_settings_get_default(); |
| - |
| - gchar* font_name = NULL; |
| - g_object_get(settings, "gtk-font-name", &font_name, NULL); |
| - |
| - // Temporary CHECK for helping track down |
| - // http://code.google.com/p/chromium/issues/detail?id=12530 |
| - CHECK(font_name) << " Unable to get gtk-font-name for default font."; |
| + std::string font_name = GetDefaultFont(); |
| PangoFontDescription* desc = |
| - pango_font_description_from_string(font_name); |
| + pango_font_description_from_string(font_name.c_str()); |
| default_font_ = new Font(desc); |
| pango_font_description_free(desc); |
| - g_free(font_name); |
| DCHECK(default_font_); |
| } |