I know that similar question was already asked here: How to get a current font for GtkTextView?
But
gtk_style_context_get_font has been deprecated since version 3.8 and should not be used in newly-written code. Use gtk_style_context_get() for "font" or subproperties instead.
And here I am stuck. How to use the new recommended technique to find out the current font for the widget?
@Edit Some code:
PangoFontDescription *font_desc;
GtkStyleContext *style;
GdkRGBA fore_color;
font_desc = pango_font_description_new ();
style = gtk_widget_get_style_context (base);
gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &fore_color);
gtk_style_context_save (style);
gtk_style_context_set_state (style, 0);
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", font_desc, NULL);
gtk_style_context_restore (style);
if (G_TYPE_CHECK_INSTANCE_TYPE ((font_desc), PANGO_TYPE_FONT_DESCRIPTION)) {
printf("%s\n", "Is a font");
} else {
printf("%s\n", "Not a font");
}
printf("%s\n", pango_font_description_get_family (font_desc));
prints 'random' characters because pango_font_description_get_family
returns a NULL pointer.
Also prints 'Not a font'