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

Side by Side Diff: ui/gfx/platform_font_pango.cc

Issue 10009024: Remove WAYLAND port (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/pango_util.cc ('k') | ui/gfx/rect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/string_piece.h" 14 #include "base/string_piece.h"
15 #include "base/string_split.h" 15 #include "base/string_split.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "grit/app_locale_settings.h" 17 #include "grit/app_locale_settings.h"
18 #include "third_party/skia/include/core/SkPaint.h" 18 #include "third_party/skia/include/core/SkPaint.h"
19 #include "third_party/skia/include/core/SkTypeface.h" 19 #include "third_party/skia/include/core/SkTypeface.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
23 #include "ui/gfx/pango_util.h" 23 #include "ui/gfx/pango_util.h"
24 24
25 #if !defined(USE_WAYLAND) && defined(TOOLKIT_GTK) 25 #if defined(TOOLKIT_GTK)
26 #include <gdk/gdk.h> 26 #include <gdk/gdk.h>
27 #include <gtk/gtk.h> 27 #include <gtk/gtk.h>
28 #endif 28 #endif
29 29
30 namespace { 30 namespace {
31 31
32 // The font family name which is used when a user's application font for 32 // The font family name which is used when a user's application font for
33 // GNOME/KDE is a non-scalable one. The name should be listed in the 33 // GNOME/KDE is a non-scalable one. The name should be listed in the
34 // IsFallbackFontAllowed function in skia/ext/SkFontHost_fontconfig_direct.cpp. 34 // IsFallbackFontAllowed function in skia/ext/SkFontHost_fontconfig_direct.cpp.
35 const char* kFallbackFontFamilyName = "sans"; 35 const char* kFallbackFontFamilyName = "sans";
(...skipping 20 matching lines...) Expand all
56 FcPatternGetString(match, FC_FAMILY, 0, &match_family); 56 FcPatternGetString(match, FC_FAMILY, 0, &match_family);
57 std::string font_family(reinterpret_cast<char*>(match_family)); 57 std::string font_family(reinterpret_cast<char*>(match_family));
58 FcPatternDestroy(pattern); 58 FcPatternDestroy(pattern);
59 FcPatternDestroy(match); 59 FcPatternDestroy(match);
60 return font_family; 60 return font_family;
61 } 61 }
62 62
63 // Returns a Pango font description (suitable for parsing by 63 // Returns a Pango font description (suitable for parsing by
64 // pango_font_description_from_string()) for the default UI font. 64 // pango_font_description_from_string()) for the default UI font.
65 std::string GetDefaultFont() { 65 std::string GetDefaultFont() {
66 #if defined(USE_WAYLAND) || !defined(TOOLKIT_GTK) 66 #if !defined(TOOLKIT_GTK)
67 #if defined(OS_CHROMEOS) 67 #if defined(OS_CHROMEOS)
68 return l10n_util::GetStringUTF8(IDS_UI_FONT_FAMILY_CROS); 68 return l10n_util::GetStringUTF8(IDS_UI_FONT_FAMILY_CROS);
69 #else 69 #else
70 return "sans 10"; 70 return "sans 10";
71 #endif // defined(OS_CHROMEOS) 71 #endif // defined(OS_CHROMEOS)
72 #else 72 #else
73 GtkSettings* settings = gtk_settings_get_default(); 73 GtkSettings* settings = gtk_settings_get_default();
74 74
75 gchar* font_name = NULL; 75 gchar* font_name = NULL;
76 g_object_get(settings, "gtk-font-name", &font_name, NULL); 76 g_object_get(settings, "gtk-font-name", &font_name, NULL);
77 77
78 // Temporary CHECK for helping track down 78 // Temporary CHECK for helping track down
79 // http://code.google.com/p/chromium/issues/detail?id=12530 79 // http://code.google.com/p/chromium/issues/detail?id=12530
80 CHECK(font_name) << " Unable to get gtk-font-name for default font."; 80 CHECK(font_name) << " Unable to get gtk-font-name for default font.";
81 81
82 std::string default_font = std::string(font_name); 82 std::string default_font = std::string(font_name);
83 g_free(font_name); 83 g_free(font_name);
84 return default_font; 84 return default_font;
85 #endif // defined(USE_WAYLAND) || !defined(TOOLKIT_GTK) 85 #endif // !defined(TOOLKIT_GTK)
86 } 86 }
87 87
88 } // namespace 88 } // namespace
89 89
90 namespace gfx { 90 namespace gfx {
91 91
92 Font* PlatformFontPango::default_font_ = NULL; 92 Font* PlatformFontPango::default_font_ = NULL;
93 93
94 //////////////////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////////////
95 // PlatformFontPango, public: 95 // PlatformFontPango, public:
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 return new PlatformFontPango(native_font); 400 return new PlatformFontPango(native_font);
401 } 401 }
402 402
403 // static 403 // static
404 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 404 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
405 int font_size) { 405 int font_size) {
406 return new PlatformFontPango(font_name, font_size); 406 return new PlatformFontPango(font_name, font_size);
407 } 407 }
408 408
409 } // namespace gfx 409 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/pango_util.cc ('k') | ui/gfx/rect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698