From db50849d7918cc4337042e22b29ce13377e3d454 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Jun 2016 00:29:05 -0400 Subject: [PATCH] Add a function to get a font from a css style Similar in spirit to gtk_style_context_get (ctx, state, "font", ...) but avoids the need for a style context. This will be used to for css-styled text rendering from css subnodes. --- gtk/gtkcssstyle.c | 19 +++++++++++++++++++ gtk/gtkcssstyleprivate.h | 1 + 2 files changed, 20 insertions(+) diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index f4a84a1e74..1d607d8367 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -264,3 +264,22 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) return attrs; } + +static GtkCssValue * +query_func (guint id, + gpointer values) +{ + return gtk_css_style_get_value (values, id); +} + +PangoFontDescription * +gtk_css_style_get_pango_font (GtkCssStyle *style) +{ + GtkStyleProperty *prop; + GValue value = { 0, }; + + prop = _gtk_style_property_lookup ("font"); + _gtk_style_property_query (prop, &value, query_func, style); + + return (PangoFontDescription *)g_value_get_boxed (&value); +} diff --git a/gtk/gtkcssstyleprivate.h b/gtk/gtkcssstyleprivate.h index 049574a450..536b4b8a23 100644 --- a/gtk/gtkcssstyleprivate.h +++ b/gtk/gtkcssstyleprivate.h @@ -76,6 +76,7 @@ gboolean gtk_css_style_print (GtkCssStyle gboolean skip_initial); PangoAttrList * gtk_css_style_get_pango_attributes (GtkCssStyle *style); +PangoFontDescription * gtk_css_style_get_pango_font (GtkCssStyle *style); G_END_DECLS