diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-12-03 23:13:13 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-12-04 00:09:44 -0500 |
commit | d184088cae96e0d05f96c923167b260e7832d82e (patch) | |
tree | b813aa2f6c20dd1f63ef5416fb7e5f1d8980fe8a | |
parent | d0b7ccc2c532baec1eb0ef2b3e882a2e0ce1a79e (diff) | |
download | gtk+-d184088cae96e0d05f96c923167b260e7832d82e.tar.gz |
GtkTextView: Add fallback and letter-spacing support
Add support for the Pango attributes controlling font fallback
and letter spacing to GtkTextTag.
https://bugzilla.gnome.org/show_bug.cgi?id=740954
-rw-r--r-- | gtk/gtktextattributes.c | 12 | ||||
-rw-r--r-- | gtk/gtktextattributes.h | 6 | ||||
-rw-r--r-- | gtk/gtktextlayout.c | 18 | ||||
-rw-r--r-- | gtk/gtktexttag.c | 72 | ||||
-rw-r--r-- | gtk/gtktexttagprivate.h | 2 |
5 files changed, 107 insertions, 3 deletions
diff --git a/gtk/gtktextattributes.c b/gtk/gtktextattributes.c index 5998bd398c..b864f39bd3 100644 --- a/gtk/gtktextattributes.c +++ b/gtk/gtktextattributes.c @@ -378,6 +378,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS if (tag->priv->language_set) dest->language = vals->language; + if (tag->priv->fallback_set) + dest->no_fallback = vals->no_fallback; + + if (tag->priv->letter_spacing_set) + dest->letter_spacing = vals->letter_spacing; + ++n; } @@ -404,7 +410,8 @@ _gtk_text_tag_affects_size (GtkTextTag *tag) priv->tabs_set || priv->underline_set || priv->wrap_mode_set || - priv->invisible_set; + priv->invisible_set || + priv->letter_spacing_set; } gboolean @@ -417,5 +424,6 @@ _gtk_text_tag_affects_nonsize_appearance (GtkTextTag *tag) priv->fg_color_set || priv->strikethrough_set || priv->bg_full_height_set || - priv->pg_bg_color_set; + priv->pg_bg_color_set || + priv->fallback_set; } diff --git a/gtk/gtktextattributes.h b/gtk/gtktextattributes.h index 0e2f85b0b8..0a57c69bd4 100644 --- a/gtk/gtktextattributes.h +++ b/gtk/gtktextattributes.h @@ -210,11 +210,15 @@ struct _GtkTextAttributes /* can edit this text */ guint editable : 1; + guint no_fallback: 1; + /*< private >*/ /* Paragraph background */ GdkRGBA *pg_bg_rgba; - guint padding[3]; + gint letter_spacing; + + guint padding[2]; }; GDK_AVAILABLE_IN_ALL diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 7dbb62e13b..44b87bbd99 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -1580,6 +1580,24 @@ add_text_attrs (GtkTextLayout *layout, pango_attr_list_insert (attrs, attr); } + + if (style->no_fallback) + { + attr = pango_attr_fallback_new (!style->no_fallback); + attr->start_index = start; + attr->end_index = start + byte_count; + + pango_attr_list_insert (attrs, attr); + } + + if (style->letter_spacing != 0) + { + attr = pango_attr_letter_spacing_new (style->letter_spacing); + attr->start_index = start; + attr->end_index = start + byte_count; + + pango_attr_list_insert (attrs, attr); + } } static void diff --git a/gtk/gtktexttag.c b/gtk/gtktexttag.c index 6e16fd6689..f02ae45c32 100644 --- a/gtk/gtktexttag.c +++ b/gtk/gtktexttag.c @@ -129,6 +129,8 @@ enum { PROP_PARAGRAPH_BACKGROUND, PROP_PARAGRAPH_BACKGROUND_GDK, PROP_PARAGRAPH_BACKGROUND_RGBA, + PROP_FALLBACK, + PROP_LETTER_SPACING, /* Behavior args */ PROP_ACCUMULATIVE_MARGIN, @@ -160,6 +162,8 @@ enum { PROP_TABS_SET, PROP_INVISIBLE_SET, PROP_PARAGRAPH_BACKGROUND_SET, + PROP_FALLBACK_SET, + PROP_LETTER_SPACING_SET, LAST_ARG }; @@ -600,6 +604,38 @@ gtk_text_tag_class_init (GtkTextTagClass *klass) GTK_PARAM_READWRITE)); /** + * GtkTextTag:fallback: + * + * Whether font fallback is enabled. + * + * When set to %TRUE, other fonts will be substituted + * where the current font is missing glyphs. + * + * Since: 3.16 + */ + g_object_class_install_property (object_class, + PROP_FALLBACK, + g_param_spec_boolean ("fallback", + P_("Fallback"), + P_("Whether font fallback is enabled."), + TRUE, + GTK_PARAM_READWRITE)); + + /** + * GtkTextTag:letter-spacing: + * + * Extra spacing between graphemes, in Pango units. + * + * Since: 3.16 + */ + g_object_class_install_property (object_class, + PROP_LETTER_SPACING, + g_param_spec_int ("letter-spacing", + P_("Letter Spacing"), + P_("Extra spacing between graphemes"), + 0, G_MAXINT, 0, + GTK_PARAM_READWRITE)); + /** * GtkTextTag:accumulative-margin: * * Whether the margins accumulate or override each other. @@ -726,6 +762,14 @@ gtk_text_tag_class_init (GtkTextTagClass *klass) P_("Paragraph background set"), P_("Whether this tag affects the paragraph background color")); + ADD_SET_PROP ("fallback-set", PROP_FALLBACK_SET, + P_("Fallback set"), + P_("Whether this tag affects font fallback")); + + ADD_SET_PROP ("letter-spacing-set", PROP_LETTER_SPACING_SET, + P_("Letter spacing set"), + P_("Whether this tag affects letter spacing")); + /** * GtkTextTag::event: * @tag: the #GtkTextTag on which the signal is emitted @@ -1450,6 +1494,18 @@ gtk_text_tag_set_property (GObject *object, } break; + case PROP_FALLBACK: + priv->fallback_set = TRUE; + priv->values->no_fallback = !g_value_get_boolean (value); + g_object_notify (object, "fallback-set"); + break; + + case PROP_LETTER_SPACING: + priv->letter_spacing_set = TRUE; + priv->values->letter_spacing = g_value_get_int (value); + g_object_notify (object, "letter-spacing-set"); + break; + case PROP_ACCUMULATIVE_MARGIN: priv->accumulative_margin = g_value_get_boolean (value); g_object_notify (object, "accumulative-margin"); @@ -1763,6 +1819,14 @@ gtk_text_tag_get_property (GObject *object, g_value_set_boxed (value, priv->values->pg_bg_rgba); break; + case PROP_FALLBACK: + g_value_set_boolean (value, !priv->values->no_fallback); + break; + + case PROP_LETTER_SPACING: + g_value_set_int (value, priv->values->letter_spacing); + break; + case PROP_ACCUMULATIVE_MARGIN: g_value_set_boolean (value, priv->accumulative_margin); break; @@ -1861,6 +1925,14 @@ gtk_text_tag_get_property (GObject *object, g_value_set_boolean (value, priv->pg_bg_color_set); break; + case PROP_FALLBACK_SET: + g_value_set_boolean (value, priv->fallback_set); + break; + + case PROP_LETTER_SPACING_SET: + g_value_set_boolean (value, priv->letter_spacing_set); + break; + case PROP_BACKGROUND: case PROP_FOREGROUND: case PROP_PARAGRAPH_BACKGROUND: diff --git a/gtk/gtktexttagprivate.h b/gtk/gtktexttagprivate.h index 4942b27890..cd31b7cb2c 100644 --- a/gtk/gtktexttagprivate.h +++ b/gtk/gtktexttagprivate.h @@ -75,6 +75,8 @@ struct _GtkTextTagPrivate guint editable_set : 1; guint language_set : 1; guint pg_bg_color_set : 1; + guint fallback_set : 1; + guint letter_spacing_set : 1; /* Whether these margins accumulate or override */ guint accumulative_margin : 1; |