summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <christian@hergert.me>2015-10-02 01:18:41 -0700
committerChristian Hergert <christian@hergert.me>2015-10-02 01:18:50 -0700
commitbf0eae65cd1373622892487cba135a732d5d9c65 (patch)
tree5dc5ec84b3c191ffd1c0b77e26f2d96584cff70d
parentaffae0222e39f6f31c1adb10c3d02bca9e9c73cf (diff)
downloadgtksourceview-bf0eae65cd1373622892487cba135a732d5d9c65.tar.gz
completion: workaround GtkCellRendererText bug
If a completion proposal returns markup of "<b>foo</b> <b>foo</b>", the first bold will not be respected in most cases. The font-desc we get from the style usually has PANGO_FONT_MASK_WEIGHT set, even when it is set to normal. Thus, the PangoLayout has two PangoAttr in the PangoAttrList which set weight at the same offset. This can be removed if https://bugzilla.gnome.org/show_bug.cgi?id=755968 gets fixed.
-rw-r--r--gtksourceview/gtksourcecompletion.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index ae082b66..3f574b63 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1577,6 +1577,19 @@ style_context_changed (GtkStyleContext *style_context,
gtk_style_context_get (style_context, GTK_STATE_FLAG_NORMAL,
GTK_STYLE_PROPERTY_FONT, &font_desc,
NULL);
+ /*
+ * Work around issue where when a proposal provides "<b>markup</b>" and
+ * the weight is set in the font description, the <b> markup will not
+ * have it's weight respected. This seems to be happening because the
+ * weight mask is getting set in pango_font_description_from_string()
+ * even if the the value is set to normal. That matter is complicated
+ * because PangoAttrFontDesc and PangoAttrWeight will both have the
+ * same starting offset in the PangoLayout.
+ */
+ if (PANGO_WEIGHT_NORMAL == pango_font_description_get_weight (font_desc))
+ {
+ pango_font_description_unset_fields (font_desc, PANGO_FONT_MASK_WEIGHT);
+ }
g_object_set (completion->priv->cell_renderer_proposal,
"font-desc", font_desc,
NULL);