| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pango_util.h" | 5 #include "ui/gfx/pango_util.h" |
| 6 | 6 |
| 7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
| 8 #include <gtk/gtk.h> | |
| 9 #include <pango/pango.h> | 8 #include <pango/pango.h> |
| 10 #include <pango/pangocairo.h> | 9 #include <pango/pangocairo.h> |
| 11 | 10 |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 14 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
| 16 | 15 |
| 17 #if !defined(USE_WAYLAND) | 16 #if !defined(USE_WAYLAND) && defined(TOOLKIT_USES_GTK) |
| 17 #include <gtk/gtk.h> |
| 18 #include "ui/gfx/gtk_util.h" | 18 #include "ui/gfx/gtk_util.h" |
| 19 #else | 19 #else |
| 20 #include "ui/gfx/linux_util.h" | 20 #include "ui/gfx/linux_util.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #include "ui/gfx/skia_util.h" | 23 #include "ui/gfx/skia_util.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Marker for accelerators in the text. | 27 // Marker for accelerators in the text. |
| 28 const gunichar kAcceleratorChar = '&'; | 28 const gunichar kAcceleratorChar = '&'; |
| 29 | 29 |
| 30 // Return |cairo_font_options|. If needed, allocate and update it based on | 30 // Return |cairo_font_options|. If needed, allocate and update it based on |
| 31 // GtkSettings. | 31 // GtkSettings. |
| 32 cairo_font_options_t* GetCairoFontOptions() { | 32 cairo_font_options_t* GetCairoFontOptions() { |
| 33 // Font settings that we initialize once and then use when drawing text. | 33 // Font settings that we initialize once and then use when drawing text. |
| 34 static cairo_font_options_t* cairo_font_options = NULL; | 34 static cairo_font_options_t* cairo_font_options = NULL; |
| 35 | 35 |
| 36 if (cairo_font_options) | 36 if (cairo_font_options) |
| 37 return cairo_font_options; | 37 return cairo_font_options; |
| 38 | 38 |
| 39 cairo_font_options = cairo_font_options_create(); | 39 cairo_font_options = cairo_font_options_create(); |
| 40 | 40 |
| 41 gint antialias = 0; | 41 gint antialias = 0; |
| 42 gint hinting = 0; | 42 gint hinting = 0; |
| 43 gchar* hint_style = NULL; | 43 gchar* hint_style = NULL; |
| 44 gchar* rgba_style = NULL; | 44 gchar* rgba_style = NULL; |
| 45 | 45 |
| 46 #if !defined(USE_WAYLAND) && !defined(USE_AURA) | 46 #if !defined(USE_WAYLAND) && defined(TOOLKIT_USES_GTK) |
| 47 // TODO(xji): still has gtk dependency. | 47 // TODO(xji): still has gtk dependency. |
| 48 GtkSettings* gtk_settings = gtk_settings_get_default(); | 48 GtkSettings* gtk_settings = gtk_settings_get_default(); |
| 49 g_object_get(gtk_settings, | 49 g_object_get(gtk_settings, |
| 50 "gtk-xft-antialias", &antialias, | 50 "gtk-xft-antialias", &antialias, |
| 51 "gtk-xft-hinting", &hinting, | 51 "gtk-xft-hinting", &hinting, |
| 52 "gtk-xft-hintstyle", &hint_style, | 52 "gtk-xft-hintstyle", &hint_style, |
| 53 "gtk-xft-rgba", &rgba_style, | 53 "gtk-xft-rgba", &rgba_style, |
| 54 NULL); | 54 NULL); |
| 55 #endif | 55 #endif |
| 56 | 56 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 RemoveAcceleratorChar(utf8, static_cast<char>(kAcceleratorChar)); | 182 RemoveAcceleratorChar(utf8, static_cast<char>(kAcceleratorChar)); |
| 183 | 183 |
| 184 pango_layout_set_text(layout, | 184 pango_layout_set_text(layout, |
| 185 accelerator_removed.data(), accelerator_removed.size()); | 185 accelerator_removed.data(), accelerator_removed.size()); |
| 186 } else { | 186 } else { |
| 187 pango_layout_set_text(layout, utf8.data(), utf8.size()); | 187 pango_layout_set_text(layout, utf8.data(), utf8.size()); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace gfx | 191 } // namespace gfx |
| OLD | NEW |