Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 params->autohinter = true; |
|
Daniel Erat
2012/06/24 14:51:25
Why is the default for GTK being changed here?
Xianzhu
2012/06/26 12:46:45
Though GTK had a different value here, the value w
Daniel Erat
2012/06/26 14:17:12
Was WebKit always turning autohinting on automatic
| |
| 27 params->use_bitmaps = true; | |
| 27 params->hinting = FontRenderParams::HINTING_SLIGHT; | 28 params->hinting = FontRenderParams::HINTING_SLIGHT; |
| 28 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; | 29 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE; |
| 29 | 30 |
| 30 GtkSettings* gtk_settings = gtk_settings_get_default(); | 31 GtkSettings* gtk_settings = gtk_settings_get_default(); |
| 31 CHECK(gtk_settings); | 32 CHECK(gtk_settings); |
| 32 gint gtk_antialias = 0; | 33 gint gtk_antialias = 0; |
| 33 gint gtk_hinting = 0; | 34 gint gtk_hinting = 0; |
| 34 gchar* gtk_hint_style = NULL; | 35 gchar* gtk_hint_style = NULL; |
| 35 gchar* gtk_rgba = NULL; | 36 gchar* gtk_rgba = NULL; |
| 36 g_object_get(gtk_settings, | 37 g_object_get(gtk_settings, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 66 else if (strcmp(gtk_rgba, "vbgr") == 0) | 67 else if (strcmp(gtk_rgba, "vbgr") == 0) |
| 67 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VBGR; | 68 params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VBGR; |
| 68 } | 69 } |
| 69 | 70 |
| 70 g_free(gtk_hint_style); | 71 g_free(gtk_hint_style); |
| 71 g_free(gtk_rgba); | 72 g_free(gtk_rgba); |
| 72 #else | 73 #else |
| 73 // For non-GTK builds (read: Aura), just use reasonable hardcoded values. | 74 // For non-GTK builds (read: Aura), just use reasonable hardcoded values. |
| 74 params->antialiasing = true; | 75 params->antialiasing = true; |
| 75 params->autohinter = true; | 76 params->autohinter = true; |
| 77 params->use_bitmaps = true; | |
| 76 | 78 |
| 77 // Fetch default subpixel rendering settings from FontConfig. | 79 // Fetch default subpixel rendering settings from FontConfig. |
| 78 FcPattern* pattern = FcPatternCreate(); | 80 FcPattern* pattern = FcPatternCreate(); |
| 79 FcResult result; | 81 FcResult result; |
| 80 FcPattern* match = FcFontMatch(0, pattern, &result); | 82 FcPattern* match = FcFontMatch(0, pattern, &result); |
| 81 DCHECK(match); | 83 DCHECK(match); |
| 82 int fc_rgba = FC_RGBA_RGB; | 84 int fc_rgba = FC_RGBA_RGB; |
| 83 FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba); | 85 FcPatternGetInteger(match, FC_RGBA, 0, &fc_rgba); |
| 84 FcPatternDestroy(pattern); | 86 FcPatternDestroy(pattern); |
| 85 FcPatternDestroy(match); | 87 FcPatternDestroy(match); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 | 119 |
| 118 const FontRenderParams& GetDefaultFontRenderParams() { | 120 const FontRenderParams& GetDefaultFontRenderParams() { |
| 119 static bool loaded_defaults = false; | 121 static bool loaded_defaults = false; |
| 120 static FontRenderParams default_params; | 122 static FontRenderParams default_params; |
| 121 if (!loaded_defaults) | 123 if (!loaded_defaults) |
| 122 LoadDefaults(&default_params); | 124 LoadDefaults(&default_params); |
| 123 return default_params; | 125 return default_params; |
| 124 } | 126 } |
| 125 | 127 |
| 126 } // namespace gfx | 128 } // namespace gfx |
| OLD | NEW |