summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdk/gdkpango.c4
-rw-r--r--gdk/gdkscreen.c81
-rw-r--r--gdk/gdkscreen.h6
-rw-r--r--gdk/gdkscreenprivate.h1
-rw-r--r--gtk/gtksettings.c27
-rw-r--r--gtk/gtksettingsprivate.h2
-rw-r--r--gtk/gtkwidget.c12
7 files changed, 25 insertions, 108 deletions
diff --git a/gdk/gdkpango.c b/gdk/gdkpango.c
index 3d6a909245..9c431c6692 100644
--- a/gdk/gdkpango.c
+++ b/gdk/gdkpango.c
@@ -350,7 +350,6 @@ gdk_pango_context_get_for_screen (GdkScreen *screen)
{
PangoFontMap *fontmap;
PangoContext *context;
- const cairo_font_options_t *options;
double dpi;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
@@ -358,9 +357,6 @@ gdk_pango_context_get_for_screen (GdkScreen *screen)
fontmap = pango_cairo_font_map_get_default ();
context = pango_font_map_create_context (fontmap);
- options = gdk_screen_get_font_options (screen);
- pango_cairo_context_set_font_options (context, options);
-
dpi = gdk_screen_get_resolution (screen);
pango_cairo_context_set_resolution (context, dpi);
diff --git a/gdk/gdkscreen.c b/gdk/gdkscreen.c
index ee69322170..1ca9807d43 100644
--- a/gdk/gdkscreen.c
+++ b/gdk/gdkscreen.c
@@ -47,7 +47,6 @@
*/
-static void gdk_screen_finalize (GObject *object);
static void gdk_screen_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -60,7 +59,6 @@ static void gdk_screen_get_property (GObject *object,
enum
{
PROP_0,
- PROP_FONT_OPTIONS,
PROP_RESOLUTION
};
@@ -81,19 +79,10 @@ gdk_screen_class_init (GdkScreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gdk_screen_finalize;
object_class->set_property = gdk_screen_set_property;
object_class->get_property = gdk_screen_get_property;
g_object_class_install_property (object_class,
- PROP_FONT_OPTIONS,
- g_param_spec_pointer ("font-options",
- P_("Font options"),
- P_("The default font options for the screen"),
- G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
- G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property (object_class,
PROP_RESOLUTION,
g_param_spec_double ("resolution",
P_("Font resolution"),
@@ -152,17 +141,6 @@ gdk_screen_init (GdkScreen *screen)
screen->resolution = -1.;
}
-static void
-gdk_screen_finalize (GObject *object)
-{
- GdkScreen *screen = GDK_SCREEN (object);
-
- if (screen->font_options)
- cairo_font_options_destroy (screen->font_options);
-
- G_OBJECT_CLASS (gdk_screen_parent_class)->finalize (object);
-}
-
void
_gdk_screen_close (GdkScreen *screen)
{
@@ -176,59 +154,6 @@ _gdk_screen_close (GdkScreen *screen)
}
/**
- * gdk_screen_set_font_options:
- * @screen: a #GdkScreen
- * @options: (allow-none): a #cairo_font_options_t, or %NULL to unset any
- * previously set default font options.
- *
- * Sets the default font options for the screen. These
- * options will be set on any #PangoContext’s newly created
- * with gdk_pango_context_get_for_screen(). Changing the
- * default set of font options does not affect contexts that
- * have already been created.
- *
- * Since: 2.10
- **/
-void
-gdk_screen_set_font_options (GdkScreen *screen,
- const cairo_font_options_t *options)
-{
- g_return_if_fail (GDK_IS_SCREEN (screen));
-
- if (screen->font_options != options)
- {
- if (screen->font_options)
- cairo_font_options_destroy (screen->font_options);
-
- if (options)
- screen->font_options = cairo_font_options_copy (options);
- else
- screen->font_options = NULL;
-
- g_object_notify (G_OBJECT (screen), "font-options");
- }
-}
-
-/**
- * gdk_screen_get_font_options:
- * @screen: a #GdkScreen
- *
- * Gets any options previously set with gdk_screen_set_font_options().
- *
- * Returns: (nullable): the current font options, or %NULL if no
- * default font options have been set.
- *
- * Since: 2.10
- **/
-const cairo_font_options_t *
-gdk_screen_get_font_options (GdkScreen *screen)
-{
- g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
-
- return screen->font_options;
-}
-
-/**
* gdk_screen_set_resolution:
* @screen: a #GdkScreen
* @dpi: the resolution in “dots per inch”. (Physical inches aren’t actually
@@ -313,9 +238,6 @@ gdk_screen_get_property (GObject *object,
switch (prop_id)
{
- case PROP_FONT_OPTIONS:
- g_value_set_pointer (value, (gpointer) gdk_screen_get_font_options (screen));
- break;
case PROP_RESOLUTION:
g_value_set_double (value, gdk_screen_get_resolution (screen));
break;
@@ -335,9 +257,6 @@ gdk_screen_set_property (GObject *object,
switch (prop_id)
{
- case PROP_FONT_OPTIONS:
- gdk_screen_set_font_options (screen, g_value_get_pointer (value));
- break;
case PROP_RESOLUTION:
gdk_screen_set_resolution (screen, g_value_get_double (value));
break;
diff --git a/gdk/gdkscreen.h b/gdk/gdkscreen.h
index ea237c79e4..0899e1d118 100644
--- a/gdk/gdkscreen.h
+++ b/gdk/gdkscreen.h
@@ -67,12 +67,6 @@ gboolean gdk_screen_get_setting (GdkScreen *screen,
GValue *value);
GDK_AVAILABLE_IN_ALL
-void gdk_screen_set_font_options (GdkScreen *screen,
- const cairo_font_options_t *options);
-GDK_AVAILABLE_IN_ALL
-const cairo_font_options_t *gdk_screen_get_font_options (GdkScreen *screen);
-
-GDK_AVAILABLE_IN_ALL
void gdk_screen_set_resolution (GdkScreen *screen,
gdouble dpi);
GDK_AVAILABLE_IN_ALL
diff --git a/gdk/gdkscreenprivate.h b/gdk/gdkscreenprivate.h
index 941502c34e..928cdd9f33 100644
--- a/gdk/gdkscreenprivate.h
+++ b/gdk/gdkscreenprivate.h
@@ -33,7 +33,6 @@ struct _GdkScreen
{
GObject parent_instance;
- cairo_font_options_t *font_options;
gdouble resolution; /* pixels/points scale factor for fonts */
guint resolution_set : 1; /* resolution set through public API */
guint closed : 1;
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index f6d7283e07..4596752601 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -126,6 +126,7 @@ struct _GtkSettingsPrivate
gint font_size;
gboolean font_size_absolute;
gchar *font_family;
+ cairo_font_options_t *font_options;
};
struct _GtkSettingsValuePrivate
@@ -1799,6 +1800,9 @@ gtk_settings_finalize (GObject *object)
settings_update_provider (priv->screen, &priv->key_theme_provider, NULL);
g_slist_free_full (priv->style_cascades, g_object_unref);
+ if (priv->font_options)
+ cairo_font_options_destroy (priv->font_options);
+
g_free (priv->font_family);
G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object);
@@ -2996,7 +3000,9 @@ settings_update_font_options (GtkSettings *settings)
cairo_antialias_t antialias_mode;
gchar *rgba_str;
cairo_subpixel_order_t subpixel_order;
- cairo_font_options_t *options;
+
+ if (priv->font_options)
+ cairo_font_options_destroy (priv->font_options);
g_object_get (settings,
"gtk-xft-antialias", &antialias,
@@ -3005,9 +3011,9 @@ settings_update_font_options (GtkSettings *settings)
"gtk-xft-rgba", &rgba_str,
NULL);
- options = cairo_font_options_create ();
+ priv->font_options = cairo_font_options_create ();
- cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
+ cairo_font_options_set_hint_metrics (priv->font_options, CAIRO_HINT_METRICS_ON);
hint_style = CAIRO_HINT_STYLE_DEFAULT;
if (hinting == 0)
@@ -3031,7 +3037,7 @@ settings_update_font_options (GtkSettings *settings)
g_free (hint_style_str);
- cairo_font_options_set_hint_style (options, hint_style);
+ cairo_font_options_set_hint_style (priv->font_options, hint_style);
subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
if (rgba_str)
@@ -3048,7 +3054,7 @@ settings_update_font_options (GtkSettings *settings)
g_free (rgba_str);
- cairo_font_options_set_subpixel_order (options, subpixel_order);
+ cairo_font_options_set_subpixel_order (priv->font_options, subpixel_order);
antialias_mode = CAIRO_ANTIALIAS_DEFAULT;
if (antialias == 0)
@@ -3063,11 +3069,7 @@ settings_update_font_options (GtkSettings *settings)
antialias_mode = CAIRO_ANTIALIAS_GRAY;
}
- cairo_font_options_set_antialias (options, antialias_mode);
-
- gdk_screen_set_font_options (priv->screen, options);
-
- cairo_font_options_destroy (options);
+ cairo_font_options_set_antialias (priv->font_options, antialias_mode);
}
static gboolean
@@ -3260,6 +3262,11 @@ settings_update_key_theme (GtkSettings *settings)
g_free (key_theme_name);
}
+const cairo_font_options_t *
+gtk_settings_get_font_options (GtkSettings *settings)
+{
+ return settings->priv->font_options;
+}
GdkScreen *
_gtk_settings_get_screen (GtkSettings *settings)
diff --git a/gtk/gtksettingsprivate.h b/gtk/gtksettingsprivate.h
index 47f75a6297..1b1006e5d1 100644
--- a/gtk/gtksettingsprivate.h
+++ b/gtk/gtksettingsprivate.h
@@ -37,6 +37,8 @@ gboolean _gtk_settings_parse_convert (GtkRcPropertyParse
const GValue *src_value,
GParamSpec *pspec,
GValue *dest_value);
+const cairo_font_options_t *
+ gtk_settings_get_font_options (GtkSettings *settings);
GdkScreen *_gtk_settings_get_screen (GtkSettings *settings);
GtkStyleCascade *_gtk_settings_get_style_cascade (GtkSettings *settings,
gint scale);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 0fcd336ae2..cea479ebda 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10317,7 +10317,7 @@ update_pango_context (GtkWidget *widget,
{
PangoFontDescription *font_desc;
GtkStyleContext *style_context;
- GdkScreen *screen;
+ GtkSettings *settings;
cairo_font_options_t *font_options;
style_context = _gtk_widget_get_style_context (widget);
@@ -10340,21 +10340,21 @@ update_pango_context (GtkWidget *widget,
GTK_CSS_PROPERTY_DPI),
100));
- screen = gtk_widget_get_screen_unchecked (widget);
+ settings = gtk_widget_get_settings (widget);
font_options = (cairo_font_options_t*)g_object_get_qdata (G_OBJECT (widget), quark_font_options);
- if (screen && font_options)
+ if (settings && font_options)
{
cairo_font_options_t *options;
- options = cairo_font_options_copy (gdk_screen_get_font_options (screen));
+ options = cairo_font_options_copy (gtk_settings_get_font_options (settings));
cairo_font_options_merge (options, font_options);
pango_cairo_context_set_font_options (context, options);
cairo_font_options_destroy (options);
}
- else if (screen)
+ else if (settings)
{
pango_cairo_context_set_font_options (context,
- gdk_screen_get_font_options (screen));
+ gtk_settings_get_font_options (settings));
}
pango_context_set_font_map (context, gtk_widget_get_effective_font_map (widget));