[pango/pango2] Complete line style changes



commit eaa004680966461e4d60e2a89cc06b9a737a01cc
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 16 22:07:12 2022 -0400

    Complete line style changes
    
    Add dashed and wavy line style (without an implementation),
    and make overline styled as well.
    
    Update all affected callers.

 docs/pango_markup.md               | 10 +++---
 pango/pango-attr-list.c            |  8 ++---
 pango/pango-attributes.c           |  6 ++--
 pango/pango-attributes.h           | 27 +++++---------
 pango/pango-item-private.h         |  7 ++--
 pango/pango-item.c                 | 38 ++++----------------
 pango/pango-markup.c               | 10 +++---
 pango/pango-renderer.c             | 74 ++++++++++++++++++++++++--------------
 pango/pango-renderer.h             |  1 +
 pango/pango-run.c                  | 43 ++++++++++++++--------
 pango/serializer.c                 | 15 +++-----
 tests/itemize/two.expected         | 14 ++++----
 tests/markups/convenience.expected |  2 +-
 tests/markups/fail-10.markup       |  2 +-
 tests/markups/fail-28.expected     |  1 -
 tests/markups/fail-28.markup       |  1 -
 tests/markups/fail-9.expected      |  2 +-
 tests/markups/valid-10.markup      |  2 +-
 tests/markups/valid-11.markup      |  2 +-
 tests/markups/valid-12.expected    |  4 +--
 tests/markups/valid-12.markup      |  4 +--
 tests/markups/valid-13.expected    |  2 +-
 tests/markups/valid-14.expected    |  4 +--
 tests/markups/valid-18.markup      |  2 +-
 tests/markups/valid-3.markup       |  2 +-
 tests/markups/valid-4.expected     |  2 +-
 tests/testattributes.c             | 14 ++++----
 27 files changed, 144 insertions(+), 155 deletions(-)
---
diff --git a/docs/pango_markup.md b/docs/pango_markup.md
index 734829c0..4a4e8bd7 100644
--- a/docs/pango_markup.md
+++ b/docs/pango_markup.md
@@ -118,14 +118,17 @@ bgcolor
 : An RGBA color specification such as '#00FF007F' or a color name such as 'red'.
 
 underline
-: One of 'none', 'single', 'double', 'low', 'error'.
+: One of 'none', 'single', 'double', 'dashed', 'dotted' and 'wavy'.
 
 underline_color
 : The color of underlines; an RGBA color specification such as '#00FF007F' or a color
   name such as 'red'.
 
+underline_position:
+: The position of underlines, one of 'normal' or 'under'.
+
 overline
-: One of 'none' or 'single'. Overline support was added in Pango 1.46.
+: One of 'none', 'single', 'double', 'dashed', 'dotted' and 'wavy'.
 
 overline_color
 : The color of overlines; an RGBA color specification such as '#00FF007F' or a color
@@ -146,7 +149,7 @@ font_scale:
   to find the new size.
 
 strikethrough
-: 'true' or 'false' whether to strike through the text.
+: One of 'none', 'single', 'double', 'dashed', 'dotted' and 'wavy'.
 
 strikethrough_color
 : The color of strikethrough lines; an RGBA color specification such as '#00FF007F'
@@ -173,7 +176,6 @@ gravity_hint
 show
 : Specifies what special characters to show visibly. The value can be 'none'
   or a combination of 'spaces', 'line-breaks' and 'ignorables', combined with '|'.
-  Support for showing special characters was added in Pango 1.44.
 
 insert_hyphens
 : 'true' or 'false' to indicate whether hyphens should be inserted when breaking
diff --git a/pango/pango-attr-list.c b/pango/pango-attr-list.c
index 7e187206..0cf381b1 100644
--- a/pango/pango-attr-list.c
+++ b/pango/pango-attr-list.c
@@ -762,7 +762,7 @@ get_attr_value_type (PangoAttrType type)
     case PANGO_ATTR_GRAVITY_HINT: return PANGO_TYPE_GRAVITY_HINT;
     case PANGO_ATTR_UNDERLINE: return PANGO_TYPE_LINE_STYLE;
     case PANGO_ATTR_STRIKETHROUGH: return PANGO_TYPE_LINE_STYLE;
-    case PANGO_ATTR_OVERLINE: return PANGO_TYPE_OVERLINE;
+    case PANGO_ATTR_OVERLINE: return PANGO_TYPE_LINE_STYLE;
     case PANGO_ATTR_BASELINE_SHIFT: return PANGO_TYPE_BASELINE_SHIFT;
     case PANGO_ATTR_FONT_SCALE: return PANGO_TYPE_FONT_SCALE;
     case PANGO_ATTR_TEXT_TRANSFORM: return PANGO_TYPE_TEXT_TRANSFORM;
@@ -1129,7 +1129,7 @@ pango_attr_list_from_string (const char *text)
           break;
 
         case PANGO_ATTR_UNDERLINE:
-          ENUM_ATTR(underline, PangoLineStyle, PANGO_LINE_STYLE_NONE, PANGO_LINE_STYLE_DOTTED);
+          ENUM_ATTR(underline, PangoLineStyle, PANGO_LINE_STYLE_NONE, PANGO_LINE_STYLE_WAVY);
           break;
 
         case PANGO_ATTR_UNDERLINE_POSITION:
@@ -1137,7 +1137,7 @@ pango_attr_list_from_string (const char *text)
           break;
 
         case PANGO_ATTR_STRIKETHROUGH:
-          ENUM_ATTR(strikethrough, PangoLineStyle, PANGO_LINE_STYLE_NONE, PANGO_LINE_STYLE_DOTTED);
+          ENUM_ATTR(strikethrough, PangoLineStyle, PANGO_LINE_STYLE_NONE, PANGO_LINE_STYLE_WAVY);
           break;
 
         case PANGO_ATTR_RISE:
@@ -1202,7 +1202,7 @@ pango_attr_list_from_string (const char *text)
           break;
 
         case PANGO_ATTR_OVERLINE:
-          ENUM_ATTR(overline, PangoOverline, PANGO_OVERLINE_NONE, PANGO_OVERLINE_SINGLE);
+          ENUM_ATTR(overline, PangoLineStyle, PANGO_LINE_STYLE_NONE, PANGO_LINE_STYLE_WAVY);
           break;
 
         case PANGO_ATTR_OVERLINE_COLOR:
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index cbd110f6..253feca9 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -697,7 +697,7 @@ pango_attr_paragraph_new (void)
 
 /**
  * pango_attr_overline_new:
- * @overline: the overline style
+ * @style: the line style
  *
  * Create a new overline-style attribute.
  *
@@ -706,9 +706,9 @@ pango_attr_paragraph_new (void)
  *   [method@Pango.Attribute.destroy]
  */
 PangoAttribute *
-pango_attr_overline_new (PangoOverline overline)
+pango_attr_overline_new (PangoLineStyle style)
 {
-  return pango_attr_int_new (PANGO_ATTR_OVERLINE, (int)overline);
+  return pango_attr_int_new (PANGO_ATTR_OVERLINE, (int)style);
 }
 
 /**
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index 37ad85e2..a92350a8 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -149,18 +149,22 @@ PangoAttribute *        pango_attr_font_desc_new                (const PangoFont
 /**
  * PangoLineStyle:
  * @PANGO_LINE_STYLE_NONE: no line should be drawn
- * @PANGO_LINE_STYLE_SINGLE: a single line should be drawn
+ * @PANGO_LINE_STYLE_SOLID: a single line should be drawn
  * @PANGO_LINE_STYLE_DOUBLE: a double line should be drawn
+ * @PANGO_LINE_STYLE_DASHED: an dashed line should be drawn
  * @PANGO_LINE_STYLE_DOTTED: an dotted line should be drawn
+ * @PANGO_LINE_STYLE_WAVY: an wavy line should be drawn
  *
  * The `PangoLineStyle` enumeration is used to specify how
  * lines should be drawn.
  */
 typedef enum {
   PANGO_LINE_STYLE_NONE,
-  PANGO_LINE_STYLE_SINGLE,
+  PANGO_LINE_STYLE_SOLID,
   PANGO_LINE_STYLE_DOUBLE,
-  PANGO_LINE_STYLE_DOTTED
+  PANGO_LINE_STYLE_DASHED,
+  PANGO_LINE_STYLE_DOTTED,
+  PANGO_LINE_STYLE_WAVY,
 } PangoLineStyle;
 
 PANGO_AVAILABLE_IN_ALL
@@ -245,23 +249,8 @@ PangoAttribute *        pango_attr_paragraph_new                (void);
 
 PANGO_AVAILABLE_IN_ALL
 PangoAttribute *        pango_attr_insert_hyphens_new           (gboolean                     
insert_hyphens);
-
-/**
- * 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.
- */
-typedef enum {
-  PANGO_OVERLINE_NONE,
-  PANGO_OVERLINE_SINGLE
-} PangoOverline;
-
 PANGO_AVAILABLE_IN_ALL
-PangoAttribute *        pango_attr_overline_new                 (PangoOverline               overline);
+PangoAttribute *        pango_attr_overline_new                 (PangoLineStyle              style);
 PANGO_AVAILABLE_IN_ALL
 PangoAttribute *        pango_attr_overline_color_new           (PangoColor                 *color);
 
diff --git a/pango/pango-item-private.h b/pango/pango-item-private.h
index 2f4f8c97..541eb017 100644
--- a/pango/pango-item-private.h
+++ b/pango/pango-item-private.h
@@ -105,11 +105,10 @@ void               pango_item_unsplit                 (PangoItem *orig,
 typedef struct _ItemProperties ItemProperties;
 struct _ItemProperties
 {
-  guint uline_single        : 1;
-  guint uline_double        : 1;
-  guint uline_error         : 1;
+  PangoLineStyle uline_style;
   PangoUnderlinePosition uline_position;
-  guint strikethrough       : 1;
+  PangoLineStyle strikethrough_style;
+  PangoLineStyle oline_style;
   guint oline_single        : 1;
   guint showing_space       : 1;
   guint no_paragraph_break  : 1;
diff --git a/pango/pango-item.c b/pango/pango-item.c
index 25f552ea..079f5796 100644
--- a/pango/pango-item.c
+++ b/pango/pango-item.c
@@ -391,12 +391,10 @@ pango_item_get_properties (PangoItem      *item,
 {
   GSList *tmp_list = item->analysis.extra_attrs;
 
-  properties->uline_single = FALSE;
-  properties->uline_double = FALSE;
-  properties->uline_error = FALSE;
+  properties->uline_style = PANGO_LINE_STYLE_NONE;
   properties->uline_position = PANGO_UNDERLINE_POSITION_NORMAL;
-  properties->oline_single = FALSE;
-  properties->strikethrough = FALSE;
+  properties->oline_style = PANGO_LINE_STYLE_NONE;
+  properties->strikethrough_style = PANGO_LINE_STYLE_NONE;
   properties->showing_space = FALSE;
   properties->no_paragraph_break = FALSE;
   properties->letter_spacing = 0;
@@ -411,23 +409,7 @@ pango_item_get_properties (PangoItem      *item,
       switch ((int) attr->type)
         {
         case PANGO_ATTR_UNDERLINE:
-          switch (attr->int_value)
-            {
-            case PANGO_LINE_STYLE_NONE:
-              break;
-            case PANGO_LINE_STYLE_SINGLE:
-              properties->uline_single = TRUE;
-              break;
-            case PANGO_LINE_STYLE_DOUBLE:
-              properties->uline_double = TRUE;
-              break;
-            case PANGO_LINE_STYLE_DOTTED:
-              properties->uline_error = TRUE;
-              break;
-            default:
-              g_assert_not_reached ();
-              break;
-            }
+          properties->uline_style = attr->int_value;
           break;
 
         case PANGO_ATTR_UNDERLINE_POSITION:
@@ -435,19 +417,11 @@ pango_item_get_properties (PangoItem      *item,
           break;
 
         case PANGO_ATTR_OVERLINE:
-          switch (attr->int_value)
-            {
-            case PANGO_OVERLINE_SINGLE:
-              properties->oline_single = TRUE;
-              break;
-            default:
-              g_assert_not_reached ();
-              break;
-            }
+          properties->oline_style = attr->int_value;
           break;
 
         case PANGO_ATTR_STRIKETHROUGH:
-          properties->strikethrough = attr->int_value;
+          properties->strikethrough_style = attr->int_value;
           break;
 
         case PANGO_ATTR_LETTER_SPACING:
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 53f35db4..fb23a7d1 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -666,7 +666,7 @@ text_handler           (GMarkupParseContext *context G_GNUC_UNUSED,
                       /* Add the underline indicating the accelerator */
                       PangoAttribute *attr;
 
-                      attr = pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE);
+                      attr = pango_attr_underline_new (PANGO_LINE_STYLE_SOLID);
 
                       uline_index = md->index;
                       uline_len = g_utf8_next_char (p) - p;
@@ -1657,12 +1657,12 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
 
   if (G_UNLIKELY (overline))
     {
-      PangoOverline ol = PANGO_OVERLINE_NONE;
+      PangoLineStyle style = PANGO_LINE_STYLE_NONE;
 
-      if (!span_parse_enum ("overline", overline, PANGO_TYPE_OVERLINE, (int*)(void*)&ol, line_number, error))
+      if (!span_parse_enum ("overline", overline, PANGO_TYPE_LINE_STYLE, (int*)(void*)&style, line_number, 
error))
         goto error;
 
-      add_attribute (tag, pango_attr_overline_new (ol));
+      add_attribute (tag, pango_attr_overline_new (style));
     }
 
   if (G_UNLIKELY (overline_color))
@@ -2009,7 +2009,7 @@ u_parse_func        (MarkupData            *md G_GNUC_UNUSED,
                      GError               **error)
 {
   CHECK_NO_ATTRS("u");
-  add_attribute (tag, pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
+  add_attribute (tag, pango_attr_underline_new (PANGO_LINE_STYLE_SOLID));
 
   return TRUE;
 }
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index 42a9bb61..61e92b07 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -51,7 +51,7 @@ struct _LineState
   PangoRectangle strikethrough_rect;
   int strikethrough_glyphs;
 
-  PangoOverline  overline;
+  PangoLineStyle overline;
   PangoRectangle overline_rect;
 
   int logical_rect_end;
@@ -67,7 +67,6 @@ struct _PangoRendererPrivate
   PangoLines *lines;
   PangoLine *line;
   LineState *line_state;
-  PangoOverline overline;
 };
 
 static void pango_renderer_finalize                     (GObject          *gobject);
@@ -187,7 +186,9 @@ draw_underline (PangoRenderer *renderer,
                                      rect->width,
                                      rect->height);
       G_GNUC_FALLTHROUGH;
-    case PANGO_LINE_STYLE_SINGLE:
+    case PANGO_LINE_STYLE_SOLID:
+    case PANGO_LINE_STYLE_DOTTED:
+    case PANGO_LINE_STYLE_DASHED:
       pango_renderer_draw_rectangle (renderer,
                                      PANGO_RENDER_PART_UNDERLINE,
                                      rect->x,
@@ -195,7 +196,7 @@ draw_underline (PangoRenderer *renderer,
                                      rect->width,
                                      rect->height);
       break;
-    case PANGO_LINE_STYLE_DOTTED:
+    case PANGO_LINE_STYLE_WAVY:
       pango_renderer_draw_error_underline (renderer,
                                            rect->x,
                                            rect->y,
@@ -212,15 +213,26 @@ draw_overline (PangoRenderer *renderer,
                LineState     *state)
 {
   PangoRectangle *rect = &state->overline_rect;
-  PangoOverline overline = state->overline;
+  PangoLineStyle overline = state->overline;
 
-  state->overline = PANGO_OVERLINE_NONE;
+  state->overline = PANGO_LINE_STYLE_NONE;
 
   switch (overline)
     {
-    case PANGO_OVERLINE_NONE:
+    case PANGO_LINE_STYLE_NONE:
       break;
-    case PANGO_OVERLINE_SINGLE:
+    case PANGO_LINE_STYLE_DOUBLE:
+      pango_renderer_draw_rectangle (renderer,
+                                     PANGO_RENDER_PART_OVERLINE,
+                                     rect->x,
+                                     rect->y - 2 * rect->height,
+                                     rect->width,
+                                     rect->height);
+      G_GNUC_FALLTHROUGH;
+    case PANGO_LINE_STYLE_SOLID:
+    case PANGO_LINE_STYLE_DOTTED:
+    case PANGO_LINE_STYLE_DASHED:
+    case PANGO_LINE_STYLE_WAVY:
       pango_renderer_draw_rectangle (renderer,
                                      PANGO_RENDER_PART_OVERLINE,
                                      rect->x,
@@ -257,8 +269,10 @@ draw_strikethrough (PangoRenderer *renderer,
                                          rect->height);
           rect->y += rect->height;
           G_GNUC_FALLTHROUGH;
-        case PANGO_LINE_STYLE_SINGLE:
+        case PANGO_LINE_STYLE_SOLID:
         case PANGO_LINE_STYLE_DOTTED:
+        case PANGO_LINE_STYLE_DASHED:
+        case PANGO_LINE_STYLE_WAVY:
           pango_renderer_draw_rectangle (renderer,
                                          PANGO_RENDER_PART_STRIKETHROUGH,
                                          rect->x,
@@ -301,13 +315,13 @@ handle_line_state_change (PangoRenderer  *renderer,
     }
 
   if (part == PANGO_RENDER_PART_OVERLINE &&
-      state->overline != PANGO_OVERLINE_NONE)
+      state->overline != PANGO_LINE_STYLE_NONE)
     {
       PangoRectangle *rect = &state->overline_rect;
 
       rect->width = state->logical_rect_end - rect->x;
       draw_overline (renderer, state);
-      state->overline = renderer->priv->overline;
+      state->overline = renderer->overline;
       rect->x = state->logical_rect_end;
       rect->width = 0;
     }
@@ -348,7 +362,9 @@ add_underline (PangoRenderer    *renderer,
     case PANGO_LINE_STYLE_NONE:
       g_assert_not_reached ();
       break;
-    case PANGO_LINE_STYLE_SINGLE:
+    case PANGO_LINE_STYLE_SOLID:
+    case PANGO_LINE_STYLE_DASHED:
+    case PANGO_LINE_STYLE_DOTTED:
       if (renderer->underline_position == PANGO_UNDERLINE_POSITION_UNDER)
         {
           new_rect.y += ink_rect->y + ink_rect->height + underline_thickness;
@@ -356,7 +372,7 @@ add_underline (PangoRenderer    *renderer,
         }
       G_GNUC_FALLTHROUGH;
     case PANGO_LINE_STYLE_DOUBLE:
-    case PANGO_LINE_STYLE_DOTTED:
+    case PANGO_LINE_STYLE_WAVY:
       new_rect.y -= underline_position;
       if (state->underline == renderer->underline)
         {
@@ -406,14 +422,18 @@ add_overline (PangoRenderer    *renderer,
   new_rect.height = underline_thickness;
   new_rect.y = base_y;
 
-  switch (renderer->priv->overline)
+  switch (renderer->overline)
     {
-    case PANGO_OVERLINE_NONE:
+    case PANGO_LINE_STYLE_NONE:
       g_assert_not_reached ();
       break;
-    case PANGO_OVERLINE_SINGLE:
+    case PANGO_LINE_STYLE_SOLID:
+    case PANGO_LINE_STYLE_DOUBLE:
+    case PANGO_LINE_STYLE_DASHED:
+    case PANGO_LINE_STYLE_DOTTED:
+    case PANGO_LINE_STYLE_WAVY:
       new_rect.y -= ascent;
-      if (state->overline == renderer->priv->overline)
+      if (state->overline == renderer->overline)
         {
           new_rect.y = MIN (current_rect->y, new_rect.y);
           new_rect.height = MAX (current_rect->height, new_rect.height);
@@ -425,7 +445,7 @@ add_overline (PangoRenderer    *renderer,
       break;
     }
 
-  if (renderer->priv->overline == state->overline &&
+  if (renderer->overline == state->overline &&
       new_rect.y == current_rect->y &&
       new_rect.height == current_rect->height)
     {
@@ -436,7 +456,7 @@ add_overline (PangoRenderer    *renderer,
       draw_overline (renderer, state);
 
       *current_rect = new_rect;
-      state->overline = renderer->priv->overline;
+      state->overline = renderer->overline;
     }
 }
 
@@ -516,7 +536,7 @@ pango_renderer_draw_line (PangoRenderer   *renderer,
 
   state.underline = PANGO_LINE_STYLE_NONE;
   state.underline_position = PANGO_UNDERLINE_POSITION_NORMAL;
-  state.overline = PANGO_OVERLINE_NONE;
+  state.overline = PANGO_LINE_STYLE_NONE;
   state.strikethrough = PANGO_LINE_STYLE_NONE;
 
   pango_renderer_draw_runs (renderer, line->runs, line->data->text, x, y);
@@ -607,7 +627,7 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
       pango_renderer_prepare_run (renderer, run);
 
       if (renderer->underline != PANGO_LINE_STYLE_NONE ||
-          renderer->priv->overline != PANGO_OVERLINE_NONE ||
+          renderer->overline != PANGO_LINE_STYLE_NONE ||
           renderer->strikethrough != PANGO_LINE_STYLE_NONE)
         {
           ink = &ink_rect;
@@ -657,7 +677,7 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
       pango_renderer_draw_glyph_item (renderer, text, glyph_item, x + x_off, y - y_off);
 
       if (renderer->underline != PANGO_LINE_STYLE_NONE ||
-          renderer->priv->overline != PANGO_OVERLINE_NONE ||
+          renderer->overline != PANGO_LINE_STYLE_NONE ||
           renderer->strikethrough != PANGO_LINE_STYLE_NONE)
         {
           metrics = pango_font_get_metrics (item->analysis.font,
@@ -668,7 +688,7 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
                            x + x_off, y - y_off,
                            ink, logical);
 
-          if (renderer->priv->overline != PANGO_OVERLINE_NONE)
+          if (renderer->overline != PANGO_LINE_STYLE_NONE)
             add_overline (renderer, renderer->priv->line_state, metrics,
                            x + x_off, y - y_off,
                            ink, logical);
@@ -685,8 +705,8 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
           renderer->priv->line_state->underline != PANGO_LINE_STYLE_NONE)
         draw_underline (renderer, renderer->priv->line_state);
 
-      if (renderer->priv->overline == PANGO_OVERLINE_NONE &&
-          renderer->priv->line_state->overline != PANGO_OVERLINE_NONE)
+      if (renderer->overline == PANGO_LINE_STYLE_NONE &&
+          renderer->priv->line_state->overline != PANGO_LINE_STYLE_NONE)
         draw_overline (renderer, renderer->priv->line_state);
 
       if (renderer->strikethrough == PANGO_LINE_STYLE_NONE &&
@@ -1350,7 +1370,7 @@ pango_renderer_default_prepare_run (PangoRenderer  *renderer,
 
   renderer->underline = PANGO_LINE_STYLE_NONE;
   renderer->underline_position = PANGO_UNDERLINE_POSITION_NORMAL;
-  renderer->priv->overline = PANGO_OVERLINE_NONE;
+  renderer->overline = PANGO_LINE_STYLE_NONE;
   renderer->strikethrough = PANGO_LINE_STYLE_NONE;
 
   for (l = glyph_item->item->analysis.extra_attrs; l; l = l->next)
@@ -1368,7 +1388,7 @@ pango_renderer_default_prepare_run (PangoRenderer  *renderer,
           break;
 
         case PANGO_ATTR_OVERLINE:
-          renderer->priv->overline = attr->int_value;
+          renderer->overline = attr->int_value;
           break;
 
         case PANGO_ATTR_STRIKETHROUGH:
diff --git a/pango/pango-renderer.h b/pango/pango-renderer.h
index 4de0bb32..954ffea8 100644
--- a/pango/pango-renderer.h
+++ b/pango/pango-renderer.h
@@ -79,6 +79,7 @@ struct _PangoRenderer
   PangoLineStyle underline;
   PangoUnderlinePosition underline_position;
   PangoLineStyle strikethrough;
+  PangoLineStyle overline;
   int active_count;
 
   /*< public >*/
diff --git a/pango/pango-run.c b/pango/pango-run.c
index 17cb237e..23f495aa 100644
--- a/pango/pango-run.c
+++ b/pango/pango-run.c
@@ -74,27 +74,27 @@ pango_run_get_extents (PangoRun         *run,
   ItemProperties properties;
   gboolean has_underline;
   gboolean has_overline;
+  gboolean has_strikethrough;
   PangoRectangle logical;
   PangoFontMetrics *metrics = NULL;
   int y_offset;
 
   pango_item_get_properties (glyph_item->item, &properties);
 
-  has_underline = properties.uline_single ||
-                  properties.uline_double ||
-                  properties.uline_error;
-  has_overline = properties.oline_single;
+  has_underline = properties.uline_style != PANGO_LINE_STYLE_NONE;
+  has_overline = properties.oline_style != PANGO_LINE_STYLE_NONE;
+  has_strikethrough = properties.strikethrough_style != PANGO_LINE_STYLE_NONE;
 
   if (!logical_rect && (glyph_item->item->analysis.flags & PANGO_ANALYSIS_FLAG_CENTERED_BASELINE))
     logical_rect = &logical;
 
-  if (!logical_rect && (has_underline || has_overline || properties.strikethrough))
+  if (!logical_rect && (has_underline || has_overline || has_strikethrough))
     logical_rect = &logical;
 
   pango_glyph_string_extents (glyph_item->glyphs, glyph_item->item->analysis.font,
                               ink_rect, logical_rect);
 
-  if (ink_rect && (has_underline || has_overline || properties.strikethrough))
+  if (ink_rect && (has_underline || has_overline || has_strikethrough))
     {
       int underline_thickness;
       int underline_position;
@@ -122,7 +122,7 @@ pango_run_get_extents (PangoRun         *run,
        * If ink_rect->height == 0, we should adjust ink_rect->y appropriately.
        */
 
-      if (properties.strikethrough)
+      if (has_strikethrough)
         {
           if (ink_rect->height == 0)
             {
@@ -131,13 +131,23 @@ pango_run_get_extents (PangoRun         *run,
             }
         }
 
-      if (properties.oline_single)
+      if (properties.oline_style == PANGO_LINE_STYLE_SOLID ||
+          properties.oline_style == PANGO_LINE_STYLE_DASHED ||
+          properties.oline_style == PANGO_LINE_STYLE_DOTTED)
         {
           ink_rect->y -= underline_thickness;
           ink_rect->height += underline_thickness;
         }
+      else if (properties.oline_style == PANGO_LINE_STYLE_DOUBLE ||
+               properties.oline_style == PANGO_LINE_STYLE_WAVY)
+        {
+          ink_rect->y -= 3 * underline_thickness;
+          ink_rect->height += 3 * underline_thickness;
+        }
 
-      if (properties.uline_single)
+      if (properties.uline_style == PANGO_LINE_STYLE_SOLID ||
+          properties.uline_style == PANGO_LINE_STYLE_DASHED ||
+          properties.uline_style == PANGO_LINE_STYLE_DOTTED)
         {
           if (properties.uline_position == PANGO_UNDERLINE_POSITION_UNDER)
             ink_rect->height += 2 * underline_thickness;
@@ -145,12 +155,15 @@ pango_run_get_extents (PangoRun         *run,
             ink_rect->height = MAX (ink_rect->height,
                                     underline_thickness - underline_position - ink_rect->y);
         }
-      else if (properties.uline_double)
-        ink_rect->height = MAX (ink_rect->height,
-                                 3 * underline_thickness - underline_position - ink_rect->y);
-      else if (properties.uline_error)
-        ink_rect->height = MAX (ink_rect->height,
-                                3 * underline_thickness - underline_position - ink_rect->y);
+      else if (properties.uline_style == PANGO_LINE_STYLE_DOUBLE ||
+               properties.uline_style == PANGO_LINE_STYLE_WAVY)
+        {
+          if (properties.uline_position == PANGO_UNDERLINE_POSITION_UNDER)
+            ink_rect->height += 4 * underline_thickness;
+          else
+            ink_rect->height = MAX (ink_rect->height,
+                                   3 * underline_thickness - underline_position - ink_rect->y);
+        }
     }
 
   y_offset = glyph_item->y_offset;
diff --git a/pango/serializer.c b/pango/serializer.c
index 98327074..6298f48c 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -77,7 +77,9 @@ static const char *line_style_names[] = {
   "none",
   "single",
   "double",
+  "dashed",
   "dotted",
+  "wavy",
   NULL
 };
 
@@ -87,12 +89,6 @@ static const char *underline_position_names[] = {
   NULL
 };
 
-static const char *overline_names[] = {
-  "none",
-  "single",
-  NULL
-};
-
 static const char *gravity_names[] = {
   "south",
   "east",
@@ -320,6 +316,7 @@ add_attribute (GtkJsonPrinter *printer,
 
         case PANGO_ATTR_UNDERLINE:
         case PANGO_ATTR_STRIKETHROUGH:
+        case PANGO_ATTR_OVERLINE:
           gtk_json_printer_add_string (printer, "value", line_style_names[attr->int_value]);
           break;
 
@@ -327,10 +324,6 @@ add_attribute (GtkJsonPrinter *printer,
           gtk_json_printer_add_string (printer, "value", underline_position_names[attr->int_value]);
           break;
 
-        case PANGO_ATTR_OVERLINE:
-          gtk_json_printer_add_string (printer, "value", overline_names[attr->int_value]);
-          break;
-
         case PANGO_ATTR_GRAVITY:
           gtk_json_printer_add_string (printer, "value", gravity_names[attr->int_value]);
           break;
@@ -1070,7 +1063,7 @@ attr_for_type (GtkJsonParser *parser,
       break;
 
     case PANGO_ATTR_OVERLINE:
-      attr = pango_attr_overline_new ((PangoOverline) parser_select_string (parser, overline_names));
+      attr = pango_attr_overline_new ((PangoLineStyle) parser_select_string (parser, line_style_names));
       break;
 
     case PANGO_ATTR_OVERLINE_COLOR:
diff --git a/tests/itemize/two.expected b/tests/itemize/two.expected
index f2062a30..bebb70d2 100644
--- a/tests/itemize/two.expected
+++ b/tests/itemize/two.expected
@@ -1,9 +1,9 @@
 <span font="Cantarell 11">one <span font_features="tnum=0">tw<u>o</u> <span 
font_features="dlig=1">two</span> </span>th<b>r</b>ee</span>
 
-Items:  one two two th                                                              |r                |ee    
      
-Chars:  14(0)                                                                       |1(14)            |2(15) 
      
-Font:   Cantarell 11                                                                |Cantarell Bold 
11|Cantarell 11
-Script: latin                                                                       |latin            |latin 
      
-Lang:   en-us                                                                       |en-us            |en-us 
      
-Bidi:   0                                                                           |0                |0     
      
-Attrs:  8 11 font-features "dlig=1",6 7 underline single,4 12 font-features "tnum=0"|                 |      
      
+Items:  one two two th                                                             |r                |ee     
     
+Chars:  14(0)                                                                      |1(14)            |2(15)  
     
+Font:   Cantarell 11                                                               |Cantarell Bold 
11|Cantarell 11
+Script: latin                                                                      |latin            |latin  
     
+Lang:   en-us                                                                      |en-us            |en-us  
     
+Bidi:   0                                                                          |0                |0      
     
+Attrs:  8 11 font-features "dlig=1",6 7 underline solid,4 12 font-features "tnum=0"|                 |       
     
diff --git a/tests/markups/convenience.expected b/tests/markups/convenience.expected
index dba83d49..7ad91088 100644
--- a/tests/markups/convenience.expected
+++ b/tests/markups/convenience.expected
@@ -63,7 +63,7 @@ range 54 55
 range 55 67
 1 79 font-desc "Cantarell 20"
 1 79 language en
-55 67 underline single
+55 67 underline solid
 range 67 72
 1 79 font-desc "Cantarell 20"
 1 79 language en
diff --git a/tests/markups/fail-10.markup b/tests/markups/fail-10.markup
index 80edbc9d..a2b3879a 100644
--- a/tests/markups/fail-10.markup
+++ b/tests/markups/fail-10.markup
@@ -3,7 +3,7 @@
       background="#f0f0f0"
       underline="double"
       underline_color="red"
-      strikethrough="single"
+      strikethrough="solid"
       strikethrough_color="blue"
       fallback="x"
       lang="de"
diff --git a/tests/markups/fail-9.expected b/tests/markups/fail-9.expected
index fbb61383..240c4ed1 100644
--- a/tests/markups/fail-9.expected
+++ b/tests/markups/fail-9.expected
@@ -1 +1 @@
-ERROR: 'x' is not a valid value for the 'strikethrough' attribute on <span> tag, line 11; valid values are 
none/single/double/dotted
\ No newline at end of file
+ERROR: 'x' is not a valid value for the 'strikethrough' attribute on <span> tag, line 11; valid values are 
none/solid/double/dashed/dotted/wavy
\ No newline at end of file
diff --git a/tests/markups/valid-10.markup b/tests/markups/valid-10.markup
index 86853269..0b7eda76 100644
--- a/tests/markups/valid-10.markup
+++ b/tests/markups/valid-10.markup
@@ -3,7 +3,7 @@
       background="#f0f0f0"
       underline="double"
       underline_color="red"
-      strikethrough="single"
+      strikethrough="solid"
       strikethrough_color="blue"
       fallback="no"
       lang="de"
diff --git a/tests/markups/valid-11.markup b/tests/markups/valid-11.markup
index 9ded942a..45692f77 100644
--- a/tests/markups/valid-11.markup
+++ b/tests/markups/valid-11.markup
@@ -3,7 +3,7 @@
       background="#f0f0f0"
       underline="double"
       underline_color="red"
-      strikethrough="single"
+      strikethrough="solid"
       strikethrough_color="blue"
       fallback="f"
       lang="de"
diff --git a/tests/markups/valid-12.expected b/tests/markups/valid-12.expected
index 7355bafe..1cb33572 100644
--- a/tests/markups/valid-12.expected
+++ b/tests/markups/valid-12.expected
@@ -8,13 +8,13 @@ error-line
 ---
 
 range 0 8
-0 8 overline single
+0 8 overline solid
 range 8 9
 range 9 23
 9 23 overline-color #ffff00000000ffff
 range 23 24
 range 24 35
-24 35 underline single
+24 35 underline solid
 24 35 underline-position 1
 range 35 36
 range 36 47
diff --git a/tests/markups/valid-12.markup b/tests/markups/valid-12.markup
index 61fe819b..407c914c 100644
--- a/tests/markups/valid-12.markup
+++ b/tests/markups/valid-12.markup
@@ -1,5 +1,5 @@
-<span overline="single">overline</span>
+<span overline="solid">overline</span>
 <span overline_color="red">overline-color</span>
-<span underline="single" underline-position="under">single-line</span>
+<span underline="solid" underline-position="under">single-line</span>
 <span underline="double" underline-position="under">double-line</span>
 <span underline="dotted" underline-position="under">error-line</span>
diff --git a/tests/markups/valid-13.expected b/tests/markups/valid-13.expected
index 92829d01..db930c40 100644
--- a/tests/markups/valid-13.expected
+++ b/tests/markups/valid-13.expected
@@ -5,7 +5,7 @@ abc def
 
 range 0 4
 range 4 5
-4 5 underline single
+4 5 underline solid
 4 5 underline-position 1
 range 5 2147483647
 
diff --git a/tests/markups/valid-14.expected b/tests/markups/valid-14.expected
index 7d4fc8c6..9fb48e0c 100644
--- a/tests/markups/valid-14.expected
+++ b/tests/markups/valid-14.expected
@@ -4,11 +4,11 @@ abc def _x_
 ---
 
 range 0 1
-0 1 underline single
+0 1 underline solid
 0 1 underline-position 1
 range 1 4
 range 4 5
-4 5 underline single
+4 5 underline solid
 4 5 underline-position 1
 range 5 2147483647
 
diff --git a/tests/markups/valid-18.markup b/tests/markups/valid-18.markup
index ee54cb47..2de0db99 100644
--- a/tests/markups/valid-18.markup
+++ b/tests/markups/valid-18.markup
@@ -3,7 +3,7 @@
       background="#f0f0f0"
       underline="double"
       underline_color="red"
-      strikethrough="single"
+      strikethrough="solid"
       strikethrough_color="blue"
       fallback="n"
       lang="de"
diff --git a/tests/markups/valid-3.markup b/tests/markups/valid-3.markup
index 370d61cc..00b6c523 100644
--- a/tests/markups/valid-3.markup
+++ b/tests/markups/valid-3.markup
@@ -3,7 +3,7 @@
       background="#f0f0f0"
       underline="double"
       underline_color="red"
-      strikethrough="single"
+      strikethrough="solid"
       strikethrough_color="blue"
       fallback="false"
       allow_breaks="true"
diff --git a/tests/markups/valid-4.expected b/tests/markups/valid-4.expected
index 52df3afd..1c8ea29e 100644
--- a/tests/markups/valid-4.expected
+++ b/tests/markups/valid-4.expected
@@ -34,7 +34,7 @@ range 42 45
 42 54 family "Monospace"
 range 45 54
 42 54 family "Monospace"
-45 54 underline single
+45 54 underline solid
 range 54 2147483647
 
 
diff --git a/tests/testattributes.c b/tests/testattributes.c
index 63f37bdd..ef7eea20 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -48,10 +48,10 @@ test_attributes_basic (void)
   desc = pango_font_description_from_string ("Computer Modern 12");
   test_copy (pango_attr_font_desc_new (desc));
   pango_font_description_free (desc);
-  test_copy (pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
+  test_copy (pango_attr_underline_new (PANGO_LINE_STYLE_SOLID));
   test_copy (pango_attr_underline_new (PANGO_LINE_STYLE_DOTTED));
   test_copy (pango_attr_underline_color_new (&(PangoColor){100, 200, 300}));
-  test_copy (pango_attr_overline_new (PANGO_OVERLINE_SINGLE));
+  test_copy (pango_attr_overline_new (PANGO_LINE_STYLE_SOLID));
   test_copy (pango_attr_overline_color_new (&(PangoColor){100, 200, 300}));
   test_copy (pango_attr_strikethrough_new (TRUE));
   test_copy (pango_attr_strikethrough_color_new (&(PangoColor){100, 200, 300}));
@@ -226,10 +226,10 @@ test_binding_helpers (void)
   desc = pango_font_description_from_string ("Computer Modern 12");
   test_binding (pango_attr_font_desc_new (desc));
   pango_font_description_free (desc);
-  test_binding (pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
+  test_binding (pango_attr_underline_new (PANGO_LINE_STYLE_SOLID));
   test_binding (pango_attr_underline_new (PANGO_LINE_STYLE_DOTTED));
   test_binding (pango_attr_underline_color_new (&(PangoColor){100, 200, 300}));
-  test_binding (pango_attr_overline_new (PANGO_OVERLINE_SINGLE));
+  test_binding (pango_attr_overline_new (PANGO_LINE_STYLE_SOLID));
   test_binding (pango_attr_overline_color_new (&(PangoColor){100, 200, 300}));
   test_binding (pango_attr_strikethrough_new (TRUE));
   test_binding (pango_attr_strikethrough_color_new (&(PangoColor){100, 200, 300}));
@@ -1276,7 +1276,7 @@ test_merge2 (void)
   attr = attribute_from_string ("2 3 foreground #ffff00000000");
   pango_attr_list_change (list, attr);
 
-  assert_attr_list (list, "0 10 underline single\n"
+  assert_attr_list (list, "0 10 underline solid\n"
                           "0 2 foreground #00000000ffff\n"
                           "2 3 foreground #ffff00000000\n"
                           "3 10 foreground #00000000ffff");
@@ -1284,7 +1284,7 @@ test_merge2 (void)
   attr = attribute_from_string ("3 4 foreground #0000ffff0000");
   pango_attr_list_change (list, attr);
 
-  assert_attr_list (list, "0 10 underline single\n"
+  assert_attr_list (list, "0 10 underline solid\n"
                           "0 2 foreground #00000000ffff\n"
                           "2 3 foreground #ffff00000000\n"
                           "3 4 foreground #0000ffff0000\n"
@@ -1293,7 +1293,7 @@ test_merge2 (void)
   attr = attribute_from_string ("4 5 foreground #00000000ffff");
   pango_attr_list_change (list, attr);
 
-  assert_attr_list (list, "0 10 underline single\n"
+  assert_attr_list (list, "0 10 underline solid\n"
                           "0 2 foreground #00000000ffff\n"
                           "2 3 foreground #ffff00000000\n"
                           "3 4 foreground #0000ffff0000\n"


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