Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: ui/gfx/platform_font_gtk.cc

Issue 7467007: Adding Wayland support for ui/gfx (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Adding missing WaylandDisplay include Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/native_widget_types.h ('k') | ui/gfx/screen_wayland.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e7436387cca5ddb0f875737c6f885cff06ce211b 100644
--- a/ui/gfx/platform_font_gtk.cc
+++ b/ui/gfx/platform_font_gtk.cc
@@ -6,10 +6,9 @@
#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"
@@ -20,6 +19,11 @@
#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 +60,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 +113,25 @@ string16 FindBestMatchFontFamilyName(const char* family_name) {
return font_family;
}
+std::string GetDefaultFont() {
+#if defined(USE_WAYLAND)
+ return "sans 10";
+#else
+ 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 default_font = std::string(font_name);
+ g_free(font_name);
+ return default_font;
+#endif
+}
+
} // namespace
namespace gfx {
@@ -120,20 +143,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_);
}
« no previous file with comments | « ui/gfx/native_widget_types.h ('k') | ui/gfx/screen_wayland.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698