[Xfce4-commits] [apps/xfce4-dict] 01/02: Fix font styling with Gtk 3.22

noreply at xfce.org noreply at xfce.org
Wed Nov 2 00:14:21 CET 2016


This is an automated email from the git hooks/post-receive script.

andre pushed a commit to branch master
in repository apps/xfce4-dict.

commit a6e473b1c6d1297e4bde11cf28c0464dddcc303f
Author: Andre Miranda <andre42m at gmail.com>
Date:   Tue Nov 1 20:02:39 2016 -0300

    Fix font styling with Gtk 3.22
---
 lib/speedreader.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/speedreader.c b/lib/speedreader.c
index ecf4b97..a4396d6 100644
--- a/lib/speedreader.c
+++ b/lib/speedreader.c
@@ -358,6 +358,7 @@ static void sr_start(XfdSpeedReader *dialog)
 	GtkTextIter start, end;
 	gchar *css;
 	GtkCssProvider *provider;
+	PangoFontDescription *font;
 
 	/* clear the label text */
 	gtk_label_set_text(GTK_LABEL(priv->display_label), NULL);
@@ -381,8 +382,21 @@ static void sr_start(XfdSpeedReader *dialog)
 
 	/* set the font */
 	fontname = gtk_font_button_get_font_name(GTK_FONT_BUTTON(priv->button_font));
+	font = pango_font_description_from_string(fontname);
+
+	if (G_LIKELY (font))
+	{
+		css = g_strdup_printf("label { font-family: %s; font-size: %dpx; font-style: %s; font-weight: %s }",
+													pango_font_description_get_family (font),
+													pango_font_description_get_size (font) / PANGO_SCALE,
+													(pango_font_description_get_style(font) == PANGO_STYLE_ITALIC ||
+													pango_font_description_get_style(font) == PANGO_STYLE_OBLIQUE) ? "italic" : "normal",
+													(pango_font_description_get_weight(font) >= PANGO_WEIGHT_BOLD) ? "bold" : "normal");
+		pango_font_description_free (font);
+	}
+	else
+		css = g_strdup_printf("* { font: %s; }", fontname);
 
-	css = g_strdup_printf("* { font: %s; }", fontname);
 	provider = gtk_css_provider_new ();
 	gtk_css_provider_load_from_data (provider, css, -1, NULL);
 	gtk_style_context_add_provider (

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list