diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 22:17:26 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 22:17:26 +0000 |
commit | 05c453db1e7a357eb2cc1b6ac67ff32a5256bb19 (patch) | |
tree | 34a4f7e5e7062b378cab8a9c399ef4f6f5a403c5 /chrome/common/gtk_util.cc | |
parent | d6f7d56a9f137a08fc65a06aa6fab3e1038f13c6 (diff) | |
download | chromium_src-05c453db1e7a357eb2cc1b6ac67ff32a5256bb19.zip chromium_src-05c453db1e7a357eb2cc1b6ac67ff32a5256bb19.tar.gz chromium_src-05c453db1e7a357eb2cc1b6ac67ff32a5256bb19.tar.bz2 |
Linux: Pass font settings through to interstitial renderers.
BUG=18483
TESTED=restarted and visited a page with a broken SSL cert a few times while changing font settings via gnome-appearance-properties
Review URL: http://codereview.chromium.org/164094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gtk_util.cc')
-rw-r--r-- | chrome/common/gtk_util.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index 6e0d733..08658a7 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -13,6 +13,7 @@ #include "app/resource_bundle.h" #include "base/linux_util.h" #include "base/logging.h" +#include "chrome/common/renderer_preferences.h" #include "grit/theme_resources.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -432,4 +433,59 @@ GtkWidget* IndentWidget(GtkWidget* content) { return content_alignment; } +void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) { + DCHECK(prefs); + + gint antialias = 0; + gint hinting = 0; + gchar* hint_style = NULL; + gchar* rgba_style = NULL; + g_object_get(gtk_settings_get_default(), + "gtk-xft-antialias", &antialias, + "gtk-xft-hinting", &hinting, + "gtk-xft-hintstyle", &hint_style, + "gtk-xft-rgba", &rgba_style, + NULL); + + // Set some reasonable defaults. + prefs->should_antialias_text = true; + prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; + prefs->subpixel_rendering = + RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; + + // g_object_get() doesn't tell us whether the properties were present or not, + // but if they aren't (because gnome-settings-daemon isn't running), we'll get + // NULL values for the strings. + if (hint_style && rgba_style) { + prefs->should_antialias_text = antialias; + + if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { + prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE; + } else if (strcmp(hint_style, "hintslight") == 0) { + prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT; + } else if (strcmp(hint_style, "hintmedium") == 0) { + prefs->hinting = RENDERER_PREFERENCES_HINTING_MEDIUM; + } else if (strcmp(hint_style, "hintfull") == 0) { + prefs->hinting = RENDERER_PREFERENCES_HINTING_FULL; + } + + if (strcmp(rgba_style, "none") == 0) { + prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE; + } else if (strcmp(rgba_style, "rgb") == 0) { + prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; + } else if (strcmp(rgba_style, "bgr") == 0) { + prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; + } else if (strcmp(rgba_style, "vrgb") == 0) { + prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; + } else if (strcmp(rgba_style, "vbgr") == 0) { + prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; + } + } + + if (hint_style) + g_free(hint_style); + if (rgba_style) + g_free(rgba_style); +} + } // namespace gtk_util |