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

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

Issue 10544103: Chromium change of sharing some WebKit API between Android/Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For landing Created 8 years, 5 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/font_render_params_linux.h ('k') | ui/ui.gyp » ('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/font_render_params_linux.h" 5 #include "ui/gfx/font_render_params_linux.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #if defined(TOOLKIT_GTK) 9 #if defined(TOOLKIT_GTK)
10 #include <gtk/gtk.h> 10 #include <gtk/gtk.h>
11 #else 11 #else
12 #include <fontconfig/fontconfig.h> 12 #include <fontconfig/fontconfig.h>
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "ui/base/ui_base_switches.h" 14 #include "ui/base/ui_base_switches.h"
15 #endif 15 #endif
16 16
17 namespace gfx { 17 namespace gfx {
18 18
19 namespace { 19 namespace {
20 20
21 // Initializes |params| with the system's default settings. 21 // Initializes |params| with the system's default settings.
22 void LoadDefaults(FontRenderParams* params) { 22 void LoadDefaults(FontRenderParams* params) {
23 #if defined(TOOLKIT_GTK) 23 #if defined(TOOLKIT_GTK)
24 params->antialiasing = true; 24 params->antialiasing = true;
25 params->subpixel_positioning = false; 25 params->subpixel_positioning = false;
26 params->autohinter = false; 26 // TODO(wangxianzhu): autohinter is now true to keep original behavior
27 // of WebKit, but it might not be the best value.
28 params->autohinter = true;
29 params->use_bitmaps = true;
27 params->hinting = FontRenderParams::HINTING_SLIGHT; 30 params->hinting = FontRenderParams::HINTING_SLIGHT;
28 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; 31 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
29 32
30 GtkSettings* gtk_settings = gtk_settings_get_default(); 33 GtkSettings* gtk_settings = gtk_settings_get_default();
31 CHECK(gtk_settings); 34 CHECK(gtk_settings);
32 gint gtk_antialias = 0; 35 gint gtk_antialias = 0;
33 gint gtk_hinting = 0; 36 gint gtk_hinting = 0;
34 gchar* gtk_hint_style = NULL; 37 gchar* gtk_hint_style = NULL;
35 gchar* gtk_rgba = NULL; 38 gchar* gtk_rgba = NULL;
36 g_object_get(gtk_settings, 39 g_object_get(gtk_settings,
(...skipping 29 matching lines...) Expand all
66 else if (strcmp(gtk_rgba, "vbgr") == 0) 69 else if (strcmp(gtk_rgba, "vbgr") == 0)
67 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VBGR; 70 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VBGR;
68 } 71 }
69 72
70 g_free(gtk_hint_style); 73 g_free(gtk_hint_style);
71 g_free(gtk_rgba); 74 g_free(gtk_rgba);
72 #else 75 #else
73 // For non-GTK builds (read: Aura), just use reasonable hardcoded values. 76 // For non-GTK builds (read: Aura), just use reasonable hardcoded values.
74 params->antialiasing = true; 77 params->antialiasing = true;
75 params->autohinter = true; 78 params->autohinter = true;
79 params->use_bitmaps = true;
76 80
77 // Fetch default subpixel rendering settings from FontConfig. 81 // Fetch default subpixel rendering settings from FontConfig.
78 FcPattern* pattern = FcPatternCreate(); 82 FcPattern* pattern = FcPatternCreate();
79 FcResult result; 83 FcResult result;
80 FcPattern* match = FcFontMatch(0, pattern, &result); 84 FcPattern* match = FcFontMatch(0, pattern, &result);
81 DCHECK(match); 85 DCHECK(match);
82 int fc_rgba = FC_RGBA_RGB; 86 int fc_rgba = FC_RGBA_RGB;
83 FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba); 87 FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba);
84 FcPatternDestroy(pattern); 88 FcPatternDestroy(pattern);
85 FcPatternDestroy(match); 89 FcPatternDestroy(match);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 121
118 const FontRenderParams& GetDefaultFontRenderParams() { 122 const FontRenderParams& GetDefaultFontRenderParams() {
119 static bool loaded_defaults = false; 123 static bool loaded_defaults = false;
120 static FontRenderParams default_params; 124 static FontRenderParams default_params;
121 if (!loaded_defaults) 125 if (!loaded_defaults)
122 LoadDefaults(&default_params); 126 LoadDefaults(&default_params);
123 return default_params; 127 return default_params;
124 } 128 }
125 129
126 } // namespace gfx 130 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_linux.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698