summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-08-22 11:44:25 +0200
committerMatthias Clasen <mclasen@redhat.com>2019-10-31 21:23:59 -0400
commit27ede8c45f011d5351a38019332f6f3f85c83a32 (patch)
tree05636f340e78aa75e42dc3b17187781e7fc29759 /pango
parent85bdfead1b36945db251df22b2db6789cbf4cd6c (diff)
downloadpango-27ede8c45f011d5351a38019332f6f3f85c83a32.tar.gz
Add an overline attribute
Add a new PangoOverline enum, and overline and overline_color attributes, which parallel the attributes we have for underlines and strikethrough. For now, the enum just has 'none' and 'single' values.
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-attributes.c54
-rw-r--r--pango/pango-attributes.h29
-rw-r--r--pango/pango-markup.c33
3 files changed, 116 insertions, 0 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 9a80f0e1..8ff631ae 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1258,6 +1258,60 @@ pango_attr_show_new (PangoShowFlags flags)
return pango_attr_int_new (&klass, (int)flags);
}
+/**
+ * pango_attr_overline_new:
+ * @overline: the overline style
+ *
+ * Create a new overline-style attribute.
+ *
+ * Return value: (transfer full): the newly allocated #PangoAttribute,
+ * which should be freed with pango_attribute_destroy().
+ *
+ * Since: 1.45
+ **/
+PangoAttribute *
+pango_attr_overline_new (PangoOverline overline)
+{
+ static const PangoAttrClass klass = {
+ PANGO_ATTR_OVERLINE,
+ pango_attr_int_copy,
+ pango_attr_int_destroy,
+ pango_attr_int_equal
+ };
+
+ return pango_attr_int_new (&klass, (int)overline);
+}
+
+/**
+ * pango_attr_overline_color_new:
+ * @red: the red value (ranging from 0 to 65535)
+ * @green: the green value
+ * @blue: the blue value
+ *
+ * Create a new overline color attribute. This attribute
+ * modifies the color of overlines. If not set, overlines
+ * will use the foreground color.
+ *
+ * Return value: (transfer full): the newly allocated #PangoAttribute,
+ * which should be freed with pango_attribute_destroy().
+ *
+ * Since: 1.45
+ **/
+PangoAttribute *
+pango_attr_overline_color_new (guint16 red,
+ guint16 green,
+ guint16 blue)
+{
+ static const PangoAttrClass klass = {
+ PANGO_ATTR_OVERLINE_COLOR,
+ pango_attr_color_copy,
+ pango_attr_color_destroy,
+ pango_attr_color_equal
+ };
+
+ return pango_attr_color_new (&klass, red, green, blue);
+}
+
/*
* Attribute List
*/
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index ceb3236a..7def13ab 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -150,6 +150,8 @@ typedef struct _PangoAttrIterator PangoAttrIterator;
* @PANGO_ATTR_ALLOW_BREAKS: whether breaks are allowed (#PangoAttrInt). Since 1.44
* @PANGO_ATTR_SHOW: how to render invisible characters (#PangoAttrInt). Since 1.44
* @PANGO_ATTR_INSERT_HYPHENS: whether to insert hyphens at intra-word line breaks (#PangoAttrInt). Since 1.44
+ * @PANGO_ATTR_OVERLINE: whether the text has an overline (#PangoAttrInt). Sincd 1.46
+ * @PANGO_ATTR_OVERLINE_COLOR: overline color (#PangoAttrColor). Since 1.46
*
* The #PangoAttrType
* distinguishes between different types of attributes. Along with the
@@ -189,6 +191,8 @@ typedef enum
PANGO_ATTR_ALLOW_BREAKS, /* PangoAttrInt */
PANGO_ATTR_SHOW, /* PangoAttrInt */
PANGO_ATTR_INSERT_HYPHENS, /* PangoAttrInt */
+ PANGO_ATTR_OVERLINE, /* PangoAttrInt */
+ PANGO_ATTR_OVERLINE_COLOR, /* PangoAttrColor */
} PangoAttrType;
/**
@@ -232,6 +236,24 @@ typedef enum {
PANGO_UNDERLINE_ERROR_LINE
} PangoUnderline;
+
+/**
+ * PangoOverline:
+ * @PANGO_OVERLINE_NONE: no overline should be drawn
+ * @PANGO_OVERLINE_SINGLE: Draw a single line above the ink
+ * extents of the text being underlined.
+ *
+ * The #PangoOverline enumeration is used to specify
+ * whether text should be overlined, and if so, the type
+ * of line.
+ *
+ * Since: 1.46
+ */
+typedef enum {
+ PANGO_OVERLINE_NONE,
+ PANGO_OVERLINE_SINGLE
+} PangoOverline;
+
/**
* PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING:
*
@@ -545,6 +567,13 @@ PangoAttribute *pango_attr_allow_breaks_new (gboolean allow_breaks);
PANGO_AVAILABLE_IN_1_44
PangoAttribute *pango_attr_insert_hyphens_new (gboolean insert_hyphens);
+PANGO_AVAILABLE_IN_1_46
+PangoAttribute *pango_attr_overline_new (PangoOverline overline);
+PANGO_AVAILABLE_IN_1_46
+PangoAttribute *pango_attr_overline_color_new (guint16 red,
+ guint16 green,
+ guint16 blue);
+
/**
* PangoShowFlags:
* @PANGO_SHOW_NONE: No special treatment for invisible characters
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 6dce1b2e..c8499ced 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -134,6 +134,13 @@
* : The color of underlines; an RGB color
* specification such as '#00FF00' or a color name such as 'red'
*
+ * overline
+ * : One of 'none' or 'single'
+ *
+ * overline_color
+ * : The color of overlines; an RGB color
+ * specification such as '#00FF00' or a color name such as 'red'
+ *
* rise
* : Vertical displacement, in Pango units. Can be negative for
* subscript, positive for superscript.
@@ -1326,6 +1333,8 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
const char *background = NULL;
const char *underline = NULL;
const char *underline_color = NULL;
+ const char *overline = NULL;
+ const char *overline_color = NULL;
const char *strikethrough = NULL;
const char *strikethrough_color = NULL;
const char *rise = NULL;
@@ -1419,6 +1428,10 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
CHECK_ATTRIBUTE (lang);
CHECK_ATTRIBUTE (letter_spacing);
break;
+ case 'o':
+ CHECK_ATTRIBUTE (overline);
+ CHECK_ATTRIBUTE (overline_color);
+ break;
case 'u':
CHECK_ATTRIBUTE (underline);
CHECK_ATTRIBUTE (underline_color);
@@ -1661,6 +1674,26 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED,
add_attribute (tag, pango_attr_underline_color_new (color.red, color.green, color.blue));
}
+ if (G_UNLIKELY (overline))
+ {
+ PangoOverline ol = PANGO_OVERLINE_NONE;
+
+ if (!span_parse_enum ("overline", overline, PANGO_TYPE_OVERLINE, (int*)(void*)&ol, line_number, error))
+ goto error;
+
+ add_attribute (tag, pango_attr_overline_new (ol));
+ }
+
+ if (G_UNLIKELY (overline_color))
+ {
+ PangoColor color;
+
+ if (!span_parse_color ("overline_color", overline_color, &color, NULL, line_number, error))
+ goto error;
+
+ add_attribute (tag, pango_attr_overline_color_new (color.red, color.green, color.blue));
+ }
+
if (G_UNLIKELY (gravity))
{
PangoGravity gr = PANGO_GRAVITY_SOUTH;