[gtk/new-text-attributes: 3/5] textbuffer: Parse overline and hyphenation attributes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/new-text-attributes: 3/5] textbuffer: Parse overline and hyphenation attributes
- Date: Sat, 21 Mar 2020 04:00:00 +0000 (UTC)
commit 795ef5b4e347f003e9e8cf21bdeb4dbe53bda617
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 20 23:56:41 2020 -0400
textbuffer: Parse overline and hyphenation attributes
When inserting Pango markup into a text buffer, translate
Pango attributes for overlines and hyphenation control
into the corresponding text tag properties.
gtk/gtktextbuffer.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
---
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c
index c24bc61df4..610d79da10 100644
--- a/gtk/gtktextbuffer.c
+++ b/gtk/gtktextbuffer.c
@@ -4758,6 +4758,10 @@ get_tag_for_attributes (PangoAttrIterator *iter)
if (attr)
g_object_set (tag, "underline", ((PangoAttrInt*)attr)->value, NULL);
+ attr = pango_attr_iterator_get (iter, PANGO_ATTR_OVERLINE);
+ if (attr)
+ g_object_set (tag, "overline", ((PangoAttrInt*)attr)->value, NULL);
+
attr = pango_attr_iterator_get (iter, PANGO_ATTR_UNDERLINE_COLOR);
if (attr)
{
@@ -4772,6 +4776,20 @@ get_tag_for_attributes (PangoAttrIterator *iter)
g_object_set (tag, "underline-rgba", &rgba, NULL);
}
+ attr = pango_attr_iterator_get (iter, PANGO_ATTR_OVERLINE_COLOR);
+ if (attr)
+ {
+ PangoColor *color;
+ GdkRGBA rgba;
+
+ color = &((PangoAttrColor*)attr)->color;
+ rgba.red = color->red / 65535.;
+ rgba.green = color->green / 65535.;
+ rgba.blue = color->blue / 65535.;
+ rgba.alpha = 1.;
+ g_object_set (tag, "overline-rgba", &rgba, NULL);
+ }
+
attr = pango_attr_iterator_get (iter, PANGO_ATTR_STRIKETHROUGH);
if (attr)
g_object_set (tag, "strikethrough", (gboolean) (((PangoAttrInt*)attr)->value != 0), NULL);
@@ -4810,6 +4828,18 @@ get_tag_for_attributes (PangoAttrIterator *iter)
if (attr)
g_object_set (tag, "font-features", ((PangoAttrString*)attr)->value, NULL);
+ attr = pango_attr_iterator_get (iter, PANGO_ATTR_ALLOW_BREAKS);
+ if (attr)
+ g_object_set (tag, "allow-breaks", ((PangoAttrInt*)attr)->value, NULL);
+
+ attr = pango_attr_iterator_get (iter, PANGO_ATTR_SHOW);
+ if (attr)
+ g_object_set (tag, "show-spaces", ((PangoAttrInt*)attr)->value, NULL);
+
+ attr = pango_attr_iterator_get (iter, PANGO_ATTR_INSERT_HYPHENS);
+ if (attr)
+ g_object_set (tag, "insert-hyphens", ((PangoAttrInt*)attr)->value, NULL);
+
return tag;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]