[pango/pango2: 131/135] More work on line styles




commit 8e0705dc4c7a8a49338f1a7afc2e5143f56f3dbf
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 7 02:36:19 2022 -0500

    More work on line styles

 pango/pango-attr-list.c    |  4 +--
 pango/pango-attributes.c   |  6 ++--
 pango/pango-attributes.h   | 24 ++++------------
 pango/pango-item-private.h |  8 ++----
 pango/pango-item.c         | 38 ++++----------------------
 pango/pango-markup.c       |  6 ++--
 pango/pango-renderer.c     | 68 ++++++++++++++++++++++++++++++----------------
 pango/pango-renderer.h     |  2 ++
 pango/pango-run.c          | 43 +++++++++++++++++++----------
 pango/serializer.c         | 13 ++-------
 tests/testattributes.c     |  4 +--
 11 files changed, 101 insertions(+), 115 deletions(-)
---
diff --git a/pango/pango-attr-list.c b/pango/pango-attr-list.c
index 7676532e..f6470e2c 100644
--- a/pango/pango-attr-list.c
+++ b/pango/pango-attr-list.c
@@ -767,7 +767,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;
@@ -1217,7 +1217,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_DOTTED);
           break;
 
         case PANGO_ATTR_OVERLINE_COLOR:
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index b4ec828c..c8cfd1c7 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -752,7 +752,7 @@ pango_attr_paragraph_new (void)
 
 /**
  * pango_attr_overline_new:
- * @overline: the overline style
+ * @style: the line style
  *
  * Create a new overline-style attribute.
  *
@@ -763,9 +763,9 @@ pango_attr_paragraph_new (void)
  * Since: 1.46
  */
 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 e4a25c9b..8e9f7120 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -153,7 +153,9 @@ PangoAttribute *        pango_attr_font_desc_new                (const PangoFont
  * @PANGO_LINE_STYLE_NONE: no line should be drawn
  * @PANGO_LINE_STYLE_SINGLE: 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.
@@ -162,7 +164,9 @@ typedef enum {
   PANGO_LINE_STYLE_NONE,
   PANGO_LINE_STYLE_SINGLE,
   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
@@ -256,24 +260,8 @@ PangoAttribute *        pango_attr_paragraph_new                (void);
 PANGO_AVAILABLE_IN_1_44
 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.
- *
- * Since: 1.46
- */
-typedef enum {
-  PANGO_OVERLINE_NONE,
-  PANGO_OVERLINE_SINGLE
-} PangoOverline;
-
 PANGO_AVAILABLE_IN_1_46
-PangoAttribute *        pango_attr_overline_new                 (PangoOverline               overline);
+PangoAttribute *        pango_attr_overline_new                 (PangoLineStyle              style);
 PANGO_AVAILABLE_IN_1_46
 PangoAttribute *        pango_attr_overline_color_new           (PangoColor                 *color);
 
diff --git a/pango/pango-item-private.h b/pango/pango-item-private.h
index 5310c4d6..d507f9ac 100644
--- a/pango/pango-item-private.h
+++ b/pango/pango-item-private.h
@@ -57,12 +57,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;
-  guint oline_single        : 1;
+  PangoLineStyle strikethrough_style;
+  PangoLineStyle oline_style;
   guint showing_space       : 1;
   guint no_paragraph_break  : 1;
   int letter_spacing;
diff --git a/pango/pango-item.c b/pango/pango-item.c
index 831ecec3..3213ee36 100644
--- a/pango/pango-item.c
+++ b/pango/pango-item.c
@@ -376,12 +376,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->oline_style = PANGO_LINE_STYLE_NONE;
+  properties->strikethrough_style = PANGO_LINE_STYLE_NONE;
   properties->uline_position = PANGO_UNDERLINE_POSITION_NORMAL;
-  properties->oline_single = FALSE;
-  properties->strikethrough = FALSE;
   properties->showing_space = FALSE;
   properties->no_paragraph_break = FALSE;
   properties->letter_spacing = 0;
@@ -396,23 +394,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:
@@ -420,19 +402,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 b2da8e49..f8fa495a 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -1578,12 +1578,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))
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index d74223b1..69bc900a 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;
@@ -68,7 +68,6 @@ struct _PangoRendererPrivate
   PangoLines *lines;
   PangoLine *line;
   LineState *line_state;
-  PangoOverline overline;
 };
 
 static void pango_renderer_finalize                     (GObject          *gobject);
@@ -189,6 +188,8 @@ draw_underline (PangoRenderer *renderer,
                                      rect->height);
       G_GNUC_FALLTHROUGH;
     case PANGO_LINE_STYLE_SINGLE:
+    case PANGO_LINE_STYLE_DOTTED:
+    case PANGO_LINE_STYLE_DASHED:
       pango_renderer_draw_rectangle (renderer,
                                      PANGO_RENDER_PART_UNDERLINE,
                                      rect->x,
@@ -196,7 +197,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,
@@ -213,15 +214,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_SINGLE:
+    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,
@@ -260,6 +272,8 @@ draw_strikethrough (PangoRenderer *renderer,
           G_GNUC_FALLTHROUGH;
         case PANGO_LINE_STYLE_SINGLE:
         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,
@@ -302,13 +316,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;
     }
@@ -350,6 +364,8 @@ add_underline (PangoRenderer    *renderer,
       g_assert_not_reached ();
       break;
     case PANGO_LINE_STYLE_SINGLE:
+    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;
@@ -357,7 +373,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)
         {
@@ -407,14 +423,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_SINGLE:
+    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);
@@ -426,7 +446,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)
     {
@@ -437,7 +457,7 @@ add_overline (PangoRenderer    *renderer,
       draw_overline (renderer, state);
 
       *current_rect = new_rect;
-      state->overline = renderer->priv->overline;
+      state->overline = renderer->overline;
     }
 }
 
@@ -517,7 +537,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);
@@ -608,7 +628,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;
@@ -658,7 +678,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,
@@ -669,7 +689,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);
@@ -686,8 +706,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 &&
@@ -1435,7 +1455,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)
@@ -1453,7 +1473,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 a98db3ac..4f722e1f 100644
--- a/pango/pango-renderer.h
+++ b/pango/pango-renderer.h
@@ -85,6 +85,8 @@ 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 4e8680c2..898189bf 100644
--- a/pango/pango-run.c
+++ b/pango/pango-run.c
@@ -73,27 +73,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;
@@ -121,7 +121,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)
             {
@@ -130,13 +130,23 @@ pango_run_get_extents (PangoRun         *run,
             }
         }
 
-      if (properties.oline_single)
+      if (properties.oline_style == PANGO_LINE_STYLE_SINGLE ||
+          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_SINGLE ||
+          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;
@@ -144,12 +154,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 2e9249af..f1a15212 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -87,12 +87,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 +314,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 +322,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;
@@ -1102,7 +1093,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/testattributes.c b/tests/testattributes.c
index c308d67c..71144821 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -53,7 +53,7 @@ test_attributes_basic (void)
   test_copy (pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
   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_SINGLE));
   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}));
@@ -233,7 +233,7 @@ test_binding_helpers (void)
   test_binding (pango_attr_underline_new (PANGO_LINE_STYLE_SINGLE));
   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_SINGLE));
   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}));


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