[gtksourceview] completion: workaround GtkCellRendererText bug



commit bf0eae65cd1373622892487cba135a732d5d9c65
Author: Christian Hergert <christian hergert me>
Date:   Fri Oct 2 01:18:41 2015 -0700

    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.

 gtksourceview/gtksourcecompletion.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index ae082b6..3f574b6 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]