[pango/pango2: 112/118] Add alpha to PangoColor




commit 427e7ade24be79bdbce61c6efc9174f5118f2d61
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 12 22:53:53 2022 -0400

    Add alpha to PangoColor
    
    Adapt all users. This drops the alpha attributes
    and alpha in markup, and adds alpha support to
    underlines, overlines and strikethroughs.

 docs/pango_markup.md            |  29 +++-------
 pango/pango-attr-list.c         |   8 ---
 pango/pango-attr.c              |   2 -
 pango/pango-attributes.c        |  32 -----------
 pango/pango-attributes.h        |   8 ---
 pango/pango-color.c             |  83 ++++++++++++++---------------
 pango/pango-color.h             |  16 +++---
 pango/pango-markup.c            |  95 +++------------------------------
 pango/pango-renderer.c          |  73 +------------------------
 pango/pango-renderer.h          |   8 ---
 pango/pangocairo-render.c       |   8 +--
 pango/serializer.c              |   8 ---
 tests/layouts/valid-1.layout    |   6 +--
 tests/layouts/valid-7.layout    |   4 +-
 tests/markups/custom.expected   |   7 ++-
 tests/markups/fail-12.expected  |   2 +-
 tests/markups/fail-25.expected  |   2 +-
 tests/markups/fail-26.expected  |   2 +-
 tests/markups/fail-4.expected   |   1 -
 tests/markups/fail-4.markup     |   1 -
 tests/markups/valid-1.expected  |   2 +-
 tests/markups/valid-10.expected |   8 +--
 tests/markups/valid-11.expected |  24 ++++-----
 tests/markups/valid-12.expected |   2 +-
 tests/markups/valid-18.expected |   8 +--
 tests/markups/valid-19.expected |   2 +-
 tests/markups/valid-2.expected  |   2 +-
 tests/markups/valid-3.expected  |   8 +--
 tests/markups/valid-5.expected  |   8 +--
 tests/markups/valid-6.expected  |  11 ++--
 tests/markups/valid-7.expected  |   4 +-
 tests/markups/valid-8.expected  |  18 +++----
 tests/markups/valid-8.markup    |  10 ++--
 tests/testattributes.c          |  10 +---
 tests/testcolor.c               | 114 ++++++++++++++++------------------------
 tests/testserialize.c           |  10 ++--
 36 files changed, 172 insertions(+), 464 deletions(-)
---
diff --git a/docs/pango_markup.md b/docs/pango_markup.md
index 909c1a39c..734829c04 100644
--- a/docs/pango_markup.md
+++ b/docs/pango_markup.md
@@ -83,8 +83,6 @@ size
   If you want to specify a absolute size, it's usually easier to take advantage
   of the ability to specify a partial font description using 'font'; you can use
   font='12.5' rather than size='12800' or size='12.5pt'.
-  Support for specifying font sizes in points or as percentages was added in
-  Pango 1.50.
 
 font_style
 style
@@ -113,44 +111,29 @@ font_features
 foreground
 fgcolor
 color
-: An RGB color specification such as '#00FF00' or a color name such as 'red'.
-  Since 1.38, an RGBA color specification such as '#00FF007F' will be interpreted
-  as specifying both a foreground color and foreground alpha.
+: An RGBA color specification such as '#00FF007F' or a color name such as 'red'.
 
 background
 bgcolor
-: An RGB color specification such as '#00FF00' or a color name such as 'red'.
-  Since 1.38, an RGBA color specification such as '#00FF007F' will be interpreted
-  as specifying both a background color and background alpha.
-
-alpha
-fgalpha
-: An alpha value for the foreground color, either a plain integer between 1 and
-  65536 or a percentage value like '50%'.
-
-background_alpha
-bgalpha
-: An alpha value for the background color, either a plain integer between 1 and
-  65536 or a percentage value like '50%'.
+: An RGBA color specification such as '#00FF007F' or a color name such as 'red'.
 
 underline
 : One of 'none', 'single', 'double', 'low', 'error'.
 
 underline_color
-: The color of underlines; an RGB color specification such as '#00FF00' or a color
+: The color of underlines; an RGBA color specification such as '#00FF007F' or a color
   name such as 'red'.
 
 overline
 : One of 'none' or 'single'. Overline support was added in Pango 1.46.
 
 overline_color
-: The color of overlines; an RGB color specification such as '#00FF00' or a color
-  name such as 'red'. Overline support was added in Pango 1.46.
+: The color of overlines; an RGBA color specification such as '#00FF007F' or a color
+  name such as 'red'.
 
 rise
 : Vertical displacement, in Pango units or in points (e.g. '5pt'). Can be
   negative for subscript, positive for superscript.
-  Support for specifying rise in points was added in Pango 1.50.
 
 baseline_shift
 : Vertical displacement. In contrast to rise, baseline_shift attributes are cumulative.
@@ -166,7 +149,7 @@ strikethrough
 : 'true' or 'false' whether to strike through the text.
 
 strikethrough_color
-: The color of strikethrough lines; an RGB color specification such as '#00FF00'
+: The color of strikethrough lines; an RGBA color specification such as '#00FF007F'
   or a color name such as 'red'.
 
 fallback
diff --git a/pango/pango-attr-list.c b/pango/pango-attr-list.c
index 96b90ce6c..c7ad40159 100644
--- a/pango/pango-attr-list.c
+++ b/pango/pango-attr-list.c
@@ -1189,14 +1189,6 @@ pango_attr_list_from_string (const char *text)
           ENUM_ATTR(gravity_hint, PangoGravityHint, PANGO_GRAVITY_HINT_NATURAL, PANGO_GRAVITY_HINT_LINE);
           break;
 
-        case PANGO_ATTR_FOREGROUND_ALPHA:
-          INT_ATTR(foreground_alpha, int);
-          break;
-
-        case PANGO_ATTR_BACKGROUND_ALPHA:
-          INT_ATTR(background_alpha, int);
-          break;
-
         case PANGO_ATTR_ALLOW_BREAKS:
           BOOLEAN_ATTR(allow_breaks, gboolean);
           break;
diff --git a/pango/pango-attr.c b/pango/pango-attr.c
index bde919564..9640e009f 100644
--- a/pango/pango-attr.c
+++ b/pango/pango-attr.c
@@ -86,8 +86,6 @@ is_valid_attr_type (guint type)
     case PANGO_ATTR_GRAVITY:
     case PANGO_ATTR_GRAVITY_HINT:
     case PANGO_ATTR_FONT_FEATURES:
-    case PANGO_ATTR_FOREGROUND_ALPHA:
-    case PANGO_ATTR_BACKGROUND_ALPHA:
     case PANGO_ATTR_ALLOW_BREAKS:
     case PANGO_ATTR_SHOW:
     case PANGO_ATTR_INSERT_HYPHENS:
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 53bc01d10..cbd110f60 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -583,38 +583,6 @@ pango_attr_font_features_new (const char *features)
   return pango_attr_string_new (PANGO_ATTR_FONT_FEATURES, features);
 }
 
-/**
- * pango_attr_foreground_alpha_new:
- * @alpha: the alpha value, between 1 and 65536
- *
- * Create a new foreground alpha attribute.
- *
- * Return value: (transfer full): the newly allocated
- *   `PangoAttribute`, which should be freed with
- *   [method@Pango.Attribute.destroy]
- */
-PangoAttribute *
-pango_attr_foreground_alpha_new (guint16 alpha)
-{
-  return pango_attr_int_new (PANGO_ATTR_FOREGROUND_ALPHA, (int)alpha);
-}
-
-/**
- * pango_attr_background_alpha_new:
- * @alpha: the alpha value, between 1 and 65536
- *
- * Create a new background alpha attribute.
- *
- * Return value: (transfer full): the newly allocated
- *   `PangoAttribute`, which should be freed with
- *   [method@Pango.Attribute.destroy]
- */
-PangoAttribute *
-pango_attr_background_alpha_new (guint16 alpha)
-{
-  return pango_attr_int_new (PANGO_ATTR_BACKGROUND_ALPHA, (int)alpha);
-}
-
 /**
  * pango_attr_allow_breaks_new:
  * @allow_breaks: %TRUE if we line breaks are allowed
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index 7e8310e30..37ad85e26 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -57,8 +57,6 @@ G_BEGIN_DECLS
  * @PANGO_ATTR_GRAVITY: base text gravity
  * @PANGO_ATTR_GRAVITY_HINT: gravity hint
  * @PANGO_ATTR_FONT_FEATURES: OpenType font features
- * @PANGO_ATTR_FOREGROUND_ALPHA: foreground alpha
- * @PANGO_ATTR_BACKGROUND_ALPHA: background alpha
  * @PANGO_ATTR_ALLOW_BREAKS: whether line breaks are allowed
  * @PANGO_ATTR_SHOW: how to render invisible characters
  * @PANGO_ATTR_INSERT_HYPHENS: whether to insert hyphens at intra-word line breaks
@@ -106,8 +104,6 @@ typedef enum
   PANGO_ATTR_GRAVITY              = PANGO_ATTR_TYPE (INT, ITEMIZATION, OVERRIDES),
   PANGO_ATTR_GRAVITY_HINT         = PANGO_ATTR_TYPE (INT, ITEMIZATION, OVERRIDES),
   PANGO_ATTR_FONT_FEATURES        = PANGO_ATTR_TYPE (STRING, SHAPING, ACCUMULATES),
-  PANGO_ATTR_FOREGROUND_ALPHA     = PANGO_ATTR_TYPE (INT, RENDERING, OVERRIDES),
-  PANGO_ATTR_BACKGROUND_ALPHA     = PANGO_ATTR_TYPE (INT, RENDERING, OVERRIDES),
   PANGO_ATTR_ALLOW_BREAKS         = PANGO_ATTR_TYPE (BOOLEAN, BREAKING, OVERRIDES),
   PANGO_ATTR_SHOW                 = PANGO_ATTR_TYPE (INT, SHAPING, OVERRIDES),
   PANGO_ATTR_INSERT_HYPHENS       = PANGO_ATTR_TYPE (BOOLEAN, SHAPING, OVERRIDES),
@@ -239,10 +235,6 @@ PangoAttribute *        pango_attr_gravity_hint_new             (PangoGravityHin
 PANGO_AVAILABLE_IN_ALL
 PangoAttribute *        pango_attr_font_features_new            (const char                  *features);
 PANGO_AVAILABLE_IN_ALL
-PangoAttribute *        pango_attr_foreground_alpha_new         (guint16                      alpha);
-PANGO_AVAILABLE_IN_ALL
-PangoAttribute *        pango_attr_background_alpha_new         (guint16                      alpha);
-PANGO_AVAILABLE_IN_ALL
 PangoAttribute *        pango_attr_allow_breaks_new             (gboolean                     allow_breaks);
 PANGO_AVAILABLE_IN_ALL
 PangoAttribute *        pango_attr_word_new                     (void);
diff --git a/pango/pango-color.c b/pango/pango-color.c
index 03929a1b2..b2d855623 100644
--- a/pango/pango-color.c
+++ b/pango/pango-color.c
@@ -76,15 +76,36 @@ pango_color_free (PangoColor *color)
   g_slice_free (PangoColor, color);
 }
 
+/**
+ * pango_color_equal:
+ * @color1: (nullable): a `PangoColor`
+ * @color2: (nullable): another `PangoColor`
+ *
+ * Compares two colors for quality.
+ *
+ * Returns: `TRUE` if the colors are equal
+ */
+gboolean
+pango_color_equal (const PangoColor *color1,
+                   const PangoColor *color2)
+{
+  return color1 == color2 ||
+         (color1 && color2 &&
+          color1->red == color2->red &&
+          color1->green == color2->green &&
+          color1->blue == color2->blue &&
+          color1->alpha == color2->alpha);
+}
+
 /**
  * pango_color_to_string:
  * @color: a `PangoColor`
  *
  * Returns a textual specification of @color.
  *
- * The string is in the hexadecimal form `#rrrrggggbbbb`,
- * where `r`, `g` and `b` are hex digits representing the
- * red, green, and blue components respectively.
+ * The string is in the hexadecimal form `#rrrrggggbbbbaaaa`,
+ * where `r`, `g`, `b` and `a` are hex digits representing the
+ * red, green, blue and alpha components respectively.
  *
  * Return value: a newly-allocated text string that must
  *   be freed with [GLib.free]
@@ -94,7 +115,11 @@ pango_color_to_string (const PangoColor *color)
 {
   g_return_val_if_fail (color != NULL, NULL);
 
-  return g_strdup_printf ("#%04x%04x%04x", color->red, color->green, color->blue);
+  return g_strdup_printf ("#%04x%04x%04x%04x",
+                          color->red,
+                          color->green,
+                          color->blue,
+                          color->alpha);
 }
 
 /* Color parsing
@@ -209,10 +234,8 @@ hex (const char *spec,
 
 
 /**
- * pango_color_parse_with_alpha:
- * @color: (nullable): a `PangoColor` structure in which
- *   to store the result
- * @alpha: (out) (optional): return location for alpha
+ * pango_color_parse:
+ * @color: a `PangoColor` structure in which to store the result
  * @spec: a string specifying the new color
  *
  * Fill in the fields of a color from a string specification.
@@ -226,23 +249,21 @@ hex (const char *spec,
  * `#fff`, `#ffffff`, `#fffffffff` and `#ffffffffffff`.)
  *
  * Additionally, parse strings of the form `#rgba`, `#rrggbbaa`,
- * `#rrrrggggbbbbaaaa`, if @alpha is not %NULL, and set @alpha
+ * `#rrrrggggbbbbaaaa`, and set the alpha component of @color
  * to the value specified by the hex digits for `a`. If no alpha
- * component is found in @spec, @alpha is set to 0xffff (for a
+ * component is found in @spec, alpha is set to 0xffff (for a
  * solid color).
  *
  * Return value: %TRUE if parsing of the specifier succeeded,
  *   otherwise %FALSE
  */
 gboolean
-pango_color_parse_with_alpha (PangoColor *color,
-                              guint16    *alpha,
-                              const char *spec)
+pango_color_parse (PangoColor *color,
+                   const char *spec)
 {
   g_return_val_if_fail (spec != NULL, FALSE);
 
-  if (alpha)
-    *alpha = 0xffff;
+  color->alpha = 0xffff;
 
   if (spec[0] == '#')
     {
@@ -264,8 +285,6 @@ pango_color_parse_with_alpha (PangoColor *color,
         case 4:
         case 8:
         case 16:
-          if (!alpha)
-            return FALSE;
           len /= 4;
           has_alpha = TRUE;
           break;
@@ -297,7 +316,7 @@ pango_color_parse_with_alpha (PangoColor *color,
           color->blue  = b;
         }
 
-      if (alpha && has_alpha)
+      if (has_alpha)
         {
           int bits = len * 4;
           a <<= 16 - bits;
@@ -306,7 +325,7 @@ pango_color_parse_with_alpha (PangoColor *color,
               a |= (a >> bits);
               bits *= 2;
             }
-          *alpha = a;
+          color->alpha = a;
         }
     }
   else
@@ -316,29 +335,3 @@ pango_color_parse_with_alpha (PangoColor *color,
     }
   return TRUE;
 }
-
-/**
- * pango_color_parse:
- * @color: (nullable): a `PangoColor` structure in which
- *   to store the result
- * @spec: a string specifying the new color
- *
- * Fill in the fields of a color from a string specification.
- *
- * The string can either one of a large set of standard names.
- * (Taken from the CSS Color [specification](https://www.w3.org/TR/css-color-4/#named-colors),
- * or it can be a value in the form `#rgb`, `#rrggbb`,
- * `#rrrgggbbb` or `#rrrrggggbbbb`, where `r`, `g` and `b`
- * are hex digits of the red, green, and blue components
- * of the color, respectively. (White in the four forms is
- * `#fff`, `#ffffff`, `#fffffffff` and `#ffffffffffff`.)
- *
- * Return value: %TRUE if parsing of the specifier succeeded,
- *   otherwise %FALSE
- */
-gboolean
-pango_color_parse (PangoColor *color,
-                   const char *spec)
-{
-  return pango_color_parse_with_alpha (color, NULL, spec);
-}
diff --git a/pango/pango-color.h b/pango/pango-color.h
index f184d4b6a..abf4b643e 100644
--- a/pango/pango-color.h
+++ b/pango/pango-color.h
@@ -29,9 +29,10 @@ typedef struct _PangoColor PangoColor;
 
 /**
  * PangoColor:
- * @red: value of red component
- * @green: value of green component
- * @blue: value of blue component
+ * @red: value of the red component
+ * @green: value of the green component
+ * @blue: value of the blue component
+ * @alpha: value of the alpha component
  *
  * The `PangoColor` structure is used to
  * represent a color in an uncalibrated RGB color-space.
@@ -41,6 +42,7 @@ struct _PangoColor
   guint16 red;
   guint16 green;
   guint16 blue;
+  guint16 alpha;
 };
 
 #define PANGO_TYPE_COLOR (pango_color_get_type ())
@@ -55,12 +57,10 @@ PANGO_AVAILABLE_IN_ALL
 void        pango_color_free             (PangoColor       *color);
 
 PANGO_AVAILABLE_IN_ALL
-gboolean    pango_color_parse            (PangoColor       *color,
-                                          const char       *spec);
-
+gboolean    pango_color_equal            (const PangoColor *color1,
+                                          const PangoColor *color2);
 PANGO_AVAILABLE_IN_ALL
-gboolean    pango_color_parse_with_alpha (PangoColor       *color,
-                                          guint16          *alpha,
+gboolean    pango_color_parse            (PangoColor       *color,
                                           const char       *spec);
 
 PANGO_AVAILABLE_IN_ALL
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index aea2c3ca3..1786bfba7 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -1209,11 +1209,10 @@ static gboolean
 span_parse_color (const char *attr_name,
                   const char *attr_val,
                   PangoColor *color,
-                  guint16 *alpha,
                   int line_number,
                   GError **error)
 {
-  if (!pango_color_parse_with_alpha (color, alpha, attr_val))
+  if (!pango_color_parse (color, attr_val))
     {
       g_set_error (error,
                    G_MARKUP_ERROR,
@@ -1228,56 +1227,6 @@ span_parse_color (const char *attr_name,
   return TRUE;
 }
 
-static gboolean
-span_parse_alpha (const char  *attr_name,
-                  const char  *attr_val,
-                  guint16     *val,
-                  int          line_number,
-                  GError     **error)
-{
-  const char *end = attr_val;
-  int int_val;
-
-  if (_pango_scan_int (&end, &int_val))
-    {
-      if (*end == '\0' && int_val > 0 && int_val <= 0xffff)
-        {
-          *val = (guint16)int_val;
-          return TRUE;
-        }
-      else if (*end == '%' && int_val > 0 && int_val <= 100)
-        {
-          *val = (guint16)(int_val * 0xffff / 100);
-          return TRUE;
-        }
-      else
-        {
-          g_set_error (error,
-                       G_MARKUP_ERROR,
-                       G_MARKUP_ERROR_INVALID_CONTENT,
-                       _("Value of '%s' attribute on <span> tag "
-                         "on line %d could not be parsed; "
-                         "should be between 0 and 65536 or a "
-                         "percentage, not '%s'"),
-                         attr_name, line_number, attr_val);
-          return FALSE;
-        }
-    }
-  else
-    {
-      g_set_error (error,
-                   G_MARKUP_ERROR,
-                   G_MARKUP_ERROR_INVALID_CONTENT,
-                   _("Value of '%s' attribute on <span> tag "
-                     "on line %d could not be parsed; "
-                     "should be an integer, not '%s'"),
-                   attr_name, line_number, attr_val);
-      return FALSE;
-    }
-
-  return TRUE;
-}
-
 static gboolean
 span_parse_enum (const char *attr_name,
                  const char *attr_val,
@@ -1394,8 +1343,6 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
   const char *gravity = NULL;
   const char *gravity_hint = NULL;
   const char *font_features = NULL;
-  const char *alpha = NULL;
-  const char *background_alpha = NULL;
   const char *allow_breaks = NULL;
   const char *insert_hyphens = NULL;
   const char *show = NULL;
@@ -1433,13 +1380,10 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
       switch (names[i][0]) {
       case 'a':
         CHECK_ATTRIBUTE (allow_breaks);
-        CHECK_ATTRIBUTE (alpha);
         break;
       case 'b':
         CHECK_ATTRIBUTE (background);
         CHECK_ATTRIBUTE2(background, "bgcolor");
-        CHECK_ATTRIBUTE (background_alpha);
-        CHECK_ATTRIBUTE2(background_alpha, "bgalpha");
         CHECK_ATTRIBUTE(baseline_shift);
         break;
       case 'c':
@@ -1461,7 +1405,6 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
 
         CHECK_ATTRIBUTE (foreground);
         CHECK_ATTRIBUTE2(foreground, "fgcolor");
-        CHECK_ATTRIBUTE2(alpha, "fgalpha");
 
         CHECK_ATTRIBUTE (font_features);
         break;
@@ -1665,47 +1608,21 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
   if (G_UNLIKELY (foreground))
     {
       PangoColor color;
-      guint16 alpha;
 
-      if (!span_parse_color ("foreground", foreground, &color, &alpha, line_number, error))
+      if (!span_parse_color ("foreground", foreground, &color, line_number, error))
         goto error;
 
       add_attribute (tag, pango_attr_foreground_new (&color));
-      if (alpha != 0xffff)
-        add_attribute (tag, pango_attr_foreground_alpha_new (alpha));
     }
 
   if (G_UNLIKELY (background))
     {
       PangoColor color;
-      guint16 alpha;
 
-      if (!span_parse_color ("background", background, &color, &alpha, line_number, error))
+      if (!span_parse_color ("background", background, &color, line_number, error))
         goto error;
 
       add_attribute (tag, pango_attr_background_new (&color));
-      if (alpha != 0xffff)
-        add_attribute (tag, pango_attr_background_alpha_new (alpha));
-    }
-
-  if (G_UNLIKELY (alpha))
-    {
-      guint16 val;
-
-      if (!span_parse_alpha ("alpha", alpha, &val, line_number, error))
-        goto error;
-
-      add_attribute (tag, pango_attr_foreground_alpha_new (val));
-    }
-
-  if (G_UNLIKELY (background_alpha))
-    {
-      guint16 val;
-
-      if (!span_parse_alpha ("background_alpha", background_alpha, &val, line_number, error))
-        goto error;
-
-      add_attribute (tag, pango_attr_background_alpha_new (val));
     }
 
   if (G_UNLIKELY (underline))
@@ -1732,7 +1649,7 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
     {
       PangoColor color;
 
-      if (!span_parse_color ("underline_color", underline_color, &color, NULL, line_number, error))
+      if (!span_parse_color ("underline_color", underline_color, &color, line_number, error))
         goto error;
 
       add_attribute (tag, pango_attr_underline_color_new (&color));
@@ -1752,7 +1669,7 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
     {
       PangoColor color;
 
-      if (!span_parse_color ("overline_color", overline_color, &color, NULL, line_number, error))
+      if (!span_parse_color ("overline_color", overline_color, &color, line_number, error))
         goto error;
 
       add_attribute (tag, pango_attr_overline_color_new (&color));
@@ -1805,7 +1722,7 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
     {
       PangoColor color;
 
-      if (!span_parse_color ("strikethrough_color", strikethrough_color, &color, NULL, line_number, error))
+      if (!span_parse_color ("strikethrough_color", strikethrough_color, &color, line_number, error))
         goto error;
 
       add_attribute (tag, pango_attr_strikethrough_color_new (&color));
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index 4ef9b873b..37eb8dfc7 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -63,7 +63,6 @@ struct _PangoRendererPrivate
 
   PangoColor color[N_RENDER_PARTS];
   gboolean color_set[N_RENDER_PARTS];
-  guint16 alpha[N_RENDER_PARTS];
 
   PangoLines *lines;
   PangoLine *line;
@@ -1233,8 +1232,6 @@ pango_renderer_deactivate (PangoRenderer *renderer)
  * @color: (nullable): the new color or %NULL to unset the current color
  *
  * Sets the color for part of the rendering.
- *
- * Also see [method@Pango.Renderer.set_alpha].
  */
 void
 pango_renderer_set_color (PangoRenderer    *renderer,
@@ -1246,9 +1243,7 @@ pango_renderer_set_color (PangoRenderer    *renderer,
 
   if ((!color && !renderer->priv->color_set[part]) ||
       (color && renderer->priv->color_set[part] &&
-       renderer->priv->color[part].red == color->red &&
-       renderer->priv->color[part].green == color->green &&
-       renderer->priv->color[part].blue == color->blue))
+       pango_color_equal (color, &renderer->priv->color[part])))
     return;
 
   pango_renderer_part_changed (renderer, part);
@@ -1288,56 +1283,6 @@ pango_renderer_get_color (PangoRenderer   *renderer,
     return NULL;
 }
 
-/**
- * pango_renderer_set_alpha:
- * @renderer: a `PangoRenderer`
- * @part: the part to set the alpha for
- * @alpha: an alpha value between 1 and 65536, or 0 to unset the alpha
- *
- * Sets the alpha for part of the rendering.
- *
- * Note that the alpha may only be used if a color is
- * specified for @part as well.
- */
-void
-pango_renderer_set_alpha (PangoRenderer   *renderer,
-                          PangoRenderPart  part,
-                          guint16          alpha)
-{
-  g_return_if_fail (PANGO_IS_RENDERER_FAST (renderer));
-  g_return_if_fail (IS_VALID_PART (part));
-
-  if ((!alpha && !renderer->priv->alpha[part]) ||
-      (alpha && renderer->priv->alpha[part] &&
-       renderer->priv->alpha[part] == alpha))
-    return;
-
-  pango_renderer_part_changed (renderer, part);
-
-  renderer->priv->alpha[part] = alpha;
-}
-
-/**
- * pango_renderer_get_alpha:
- * @renderer: a `PangoRenderer`
- * @part: the part to get the alpha for
- *
- * Gets the current alpha for the specified part.
- *
- * Return value: the alpha for the specified part,
- *   or 0 if it hasn't been set and should be
- *   inherited from the environment.
- */
-guint16
-pango_renderer_get_alpha (PangoRenderer   *renderer,
-                          PangoRenderPart  part)
-{
-  g_return_val_if_fail (PANGO_IS_RENDERER_FAST (renderer), 0);
-  g_return_val_if_fail (IS_VALID_PART (part), 0);
-
-  return renderer->priv->alpha[part];
-}
-
 /**
  * pango_renderer_part_changed:
  * @renderer: a `PangoRenderer`
@@ -1398,8 +1343,6 @@ pango_renderer_default_prepare_run (PangoRenderer  *renderer,
   PangoColor *underline_color = NULL;
   PangoColor *overline_color = NULL;
   PangoColor *strikethrough_color = NULL;
-  guint16 fg_alpha = 0;
-  guint16 bg_alpha = 0;
   GSList *l;
   PangoGlyphItem *glyph_item;
 
@@ -1452,14 +1395,6 @@ pango_renderer_default_prepare_run (PangoRenderer  *renderer,
           strikethrough_color = &attr->color_value;
           break;
 
-        case PANGO_ATTR_FOREGROUND_ALPHA:
-          fg_alpha = attr->int_value;
-          break;
-
-        case PANGO_ATTR_BACKGROUND_ALPHA:
-          bg_alpha = attr->int_value;
-          break;
-
         default:
           break;
         }
@@ -1479,12 +1414,6 @@ pango_renderer_default_prepare_run (PangoRenderer  *renderer,
   pango_renderer_set_color (renderer, PANGO_RENDER_PART_UNDERLINE, underline_color);
   pango_renderer_set_color (renderer, PANGO_RENDER_PART_STRIKETHROUGH, strikethrough_color);
   pango_renderer_set_color (renderer, PANGO_RENDER_PART_OVERLINE, overline_color);
-
-  pango_renderer_set_alpha (renderer, PANGO_RENDER_PART_FOREGROUND, fg_alpha);
-  pango_renderer_set_alpha (renderer, PANGO_RENDER_PART_BACKGROUND, bg_alpha);
-  pango_renderer_set_alpha (renderer, PANGO_RENDER_PART_UNDERLINE, fg_alpha);
-  pango_renderer_set_alpha (renderer, PANGO_RENDER_PART_STRIKETHROUGH, fg_alpha);
-  pango_renderer_set_alpha (renderer, PANGO_RENDER_PART_OVERLINE, fg_alpha);
 }
 
 /**
diff --git a/pango/pango-renderer.h b/pango/pango-renderer.h
index 3baf4ca8d..4de0bb32c 100644
--- a/pango/pango-renderer.h
+++ b/pango/pango-renderer.h
@@ -255,14 +255,6 @@ PANGO_AVAILABLE_IN_ALL
 PangoColor *pango_renderer_get_color     (PangoRenderer    *renderer,
                                           PangoRenderPart   part);
 
-PANGO_AVAILABLE_IN_ALL
-void        pango_renderer_set_alpha     (PangoRenderer    *renderer,
-                                          PangoRenderPart   part,
-                                          guint16           alpha);
-PANGO_AVAILABLE_IN_ALL
-guint16     pango_renderer_get_alpha     (PangoRenderer    *renderer,
-                                          PangoRenderPart   part);
-
 PANGO_AVAILABLE_IN_ALL
 void               pango_renderer_set_matrix      (PangoRenderer     *renderer,
                                                    const PangoMatrix *matrix);
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index 80a6cc19f..7fb0bbe48 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -62,10 +62,9 @@ set_color (PangoCairoRenderer *crenderer,
           PangoRenderPart     part)
 {
   PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
-  guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
   gdouble red, green, blue, alpha;
 
-  if (!a && !color)
+  if (!color)
     return;
 
   if (color)
@@ -73,7 +72,7 @@ set_color (PangoCairoRenderer *crenderer,
       red = color->red / 65535.;
       green = color->green / 65535.;
       blue = color->blue / 65535.;
-      alpha = 1.;
+      alpha = color->alpha / 65535.;
     }
   else
     {
@@ -90,9 +89,6 @@ set_color (PangoCairoRenderer *crenderer,
         }
     }
 
-  if (a)
-    alpha = a / 65535.;
-
   cairo_set_source_rgba (crenderer->cr, red, green, blue, alpha);
 }
 
diff --git a/pango/serializer.c b/pango/serializer.c
index 154cf28d5..8b6ba4192 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -1057,14 +1057,6 @@ attr_for_type (GtkJsonParser *parser,
       g_free (str);
       break;
 
-    case PANGO_ATTR_FOREGROUND_ALPHA:
-      attr = pango_attr_foreground_alpha_new ((int) gtk_json_parser_get_number (parser));
-      break;
-
-    case PANGO_ATTR_BACKGROUND_ALPHA:
-      attr = pango_attr_background_alpha_new ((int) gtk_json_parser_get_number (parser));
-      break;
-
     case PANGO_ATTR_ALLOW_BREAKS:
       attr = pango_attr_allow_breaks_new (gtk_json_parser_get_boolean (parser));
       break;
diff --git a/tests/layouts/valid-1.layout b/tests/layouts/valid-1.layout
index 84375cb2d..e66988fa2 100644
--- a/tests/layouts/valid-1.layout
+++ b/tests/layouts/valid-1.layout
@@ -21,7 +21,7 @@
       "start" : 22,
       "end" : 41,
       "type" : "foreground",
-      "value" : "#00000000ffff"
+      "value" : "#00000000ffffffff"
     },
     {
       "start" : 22,
@@ -525,7 +525,7 @@
                   "start" : 22,
                   "end" : 41,
                   "type" : "foreground",
-                  "value" : "#00000000ffff"
+                  "value" : "#00000000ffffffff"
                 },
                 {
                   "start" : 22,
@@ -629,7 +629,7 @@
                   "start" : 22,
                   "end" : 41,
                   "type" : "foreground",
-                  "value" : "#00000000ffff"
+                  "value" : "#00000000ffffffff"
                 },
                 {
                   "start" : 22,
diff --git a/tests/layouts/valid-7.layout b/tests/layouts/valid-7.layout
index d340f6f57..886f88a3d 100644
--- a/tests/layouts/valid-7.layout
+++ b/tests/layouts/valid-7.layout
@@ -21,7 +21,7 @@
       "start" : 22,
       "end" : 41,
       "type" : "foreground",
-      "value" : "#00000000ffff"
+      "value" : "#00000000ffffffff"
     },
     {
       "start" : 22,
@@ -498,7 +498,7 @@
                   "start" : 22,
                   "end" : 41,
                   "type" : "foreground",
-                  "value" : "#00000000ffff"
+                  "value" : "#00000000ffffffff"
                 },
                 {
                   "start" : 22,
diff --git a/tests/markups/custom.expected b/tests/markups/custom.expected
index 5af8b0fcb..ca262a3c8 100644
--- a/tests/markups/custom.expected
+++ b/tests/markups/custom.expected
@@ -57,18 +57,17 @@ range 52 55
 1 160 font-desc "Cantarell 20"
 range 55 58
 1 160 font-desc "Cantarell 20"
-55 58 foreground #ffff00000000
+55 58 foreground #ffff00000000ffff
 range 58 61
 1 160 font-desc "Cantarell 20"
 range 61 64
 1 160 font-desc "Cantarell 20"
-61 64 foreground #ffff00000000
+61 64 foreground #ffff00000000ffff
 range 64 67
 1 160 font-desc "Cantarell 20"
 range 67 74
 1 160 font-desc "Cantarell 20"
-67 74 background #0000aaaabbbb
-67 74 background-alpha 52428
+67 74 background #0000aaaabbbbcccc
 range 74 77
 1 160 font-desc "Cantarell 20"
 range 77 81
diff --git a/tests/markups/fail-12.expected b/tests/markups/fail-12.expected
index 44893dd37..264c6dedb 100644
--- a/tests/markups/fail-12.expected
+++ b/tests/markups/fail-12.expected
@@ -1 +1 @@
-ERROR: Value of 'alpha' attribute on <span> tag on line 1 could not be parsed; should be between 0 and 65536 
or a percentage, not 'seethru'
\ No newline at end of file
+ERROR: Attribute 'alpha' is not allowed on the <span> tag on line 1 char 31
\ No newline at end of file
diff --git a/tests/markups/fail-25.expected b/tests/markups/fail-25.expected
index 482a55d74..3ace201e7 100644
--- a/tests/markups/fail-25.expected
+++ b/tests/markups/fail-25.expected
@@ -1 +1 @@
-ERROR: Value of 'alpha' attribute on <span> tag on line 1 could not be parsed; should be an integer, not 
'9999999999999'
\ No newline at end of file
+ERROR: Attribute 'alpha' is not allowed on the <span> tag on line 1 char 37
\ No newline at end of file
diff --git a/tests/markups/fail-26.expected b/tests/markups/fail-26.expected
index 73ab1be10..9f7e01cb7 100644
--- a/tests/markups/fail-26.expected
+++ b/tests/markups/fail-26.expected
@@ -1 +1 @@
-ERROR: Value of 'background_alpha' attribute on <span> tag on line 1 could not be parsed; should be an 
integer, not '9999999999999'
\ No newline at end of file
+ERROR: Attribute 'bgalpha' is not allowed on the <span> tag on line 1 char 39
\ No newline at end of file
diff --git a/tests/markups/valid-1.expected b/tests/markups/valid-1.expected
index 92e238375..6b86feb13 100644
--- a/tests/markups/valid-1.expected
+++ b/tests/markups/valid-1.expected
@@ -5,7 +5,7 @@ Blue text is cool!
 
 range 0 9
 0 9 scale 1.440000
-0 9 foreground #00000000ffff
+0 9 foreground #00000000ffffffff
 range 9 13
 range 13 17
 13 17 style italic
diff --git a/tests/markups/valid-10.expected b/tests/markups/valid-10.expected
index 7476f0bfc..8c6232110 100644
--- a/tests/markups/valid-10.expected
+++ b/tests/markups/valid-10.expected
@@ -5,14 +5,14 @@ Lots of attrs
 
 range 0 13
 0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
-0 13 foreground #0000ffff0000
-0 13 background #f0f0f0f0f0f0
+0 13 foreground #0000ffff0000ffff
+0 13 background #f0f0f0f0f0f0ffff
 0 13 underline double
-0 13 underline-color #ffff00000000
+0 13 underline-color #ffff00000000ffff
 0 13 gravity south
 0 13 gravity-hint strong
 0 13 strikethrough 1
-0 13 strikethrough-color #00000000ffff
+0 13 strikethrough-color #00000000ffffffff
 0 13 fallback false
 0 13 language de
 range 13 2147483647
diff --git a/tests/markups/valid-11.expected b/tests/markups/valid-11.expected
index 663f55e8f..6cc1f9d27 100644
--- a/tests/markups/valid-11.expected
+++ b/tests/markups/valid-11.expected
@@ -5,39 +5,39 @@ Lots of attrs
 
 range 0 5
 0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
-0 13 foreground #0000ffff0000
-0 13 background #f0f0f0f0f0f0
+0 13 foreground #0000ffff0000ffff
+0 13 background #f0f0f0f0f0f0ffff
 0 13 underline double
-0 13 underline-color #ffff00000000
+0 13 underline-color #ffff00000000ffff
 0 13 gravity south
 0 13 gravity-hint strong
 0 13 strikethrough 1
-0 13 strikethrough-color #00000000ffff
+0 13 strikethrough-color #00000000ffffffff
 0 13 fallback false
 0 13 language de
 range 5 7
 0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
-0 13 foreground #0000ffff0000
-0 13 background #f0f0f0f0f0f0
+0 13 foreground #0000ffff0000ffff
+0 13 background #f0f0f0f0f0f0ffff
 0 13 underline double
-0 13 underline-color #ffff00000000
+0 13 underline-color #ffff00000000ffff
 0 13 gravity south
 0 13 gravity-hint strong
 0 13 strikethrough 1
-0 13 strikethrough-color #00000000ffff
+0 13 strikethrough-color #00000000ffffffff
 0 13 fallback false
 0 13 language de
 5 7 font-desc "Bold"
 range 7 13
 0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
-0 13 foreground #0000ffff0000
-0 13 background #f0f0f0f0f0f0
+0 13 foreground #0000ffff0000ffff
+0 13 background #f0f0f0f0f0f0ffff
 0 13 underline double
-0 13 underline-color #ffff00000000
+0 13 underline-color #ffff00000000ffff
 0 13 gravity south
 0 13 gravity-hint strong
 0 13 strikethrough 1
-0 13 strikethrough-color #00000000ffff
+0 13 strikethrough-color #00000000ffffffff
 0 13 fallback false
 0 13 language de
 range 13 2147483647
diff --git a/tests/markups/valid-12.expected b/tests/markups/valid-12.expected
index 8c48c0845..7355bafe1 100644
--- a/tests/markups/valid-12.expected
+++ b/tests/markups/valid-12.expected
@@ -11,7 +11,7 @@ range 0 8
 0 8 overline single
 range 8 9
 range 9 23
-9 23 overline-color #ffff00000000
+9 23 overline-color #ffff00000000ffff
 range 23 24
 range 24 35
 24 35 underline single
diff --git a/tests/markups/valid-18.expected b/tests/markups/valid-18.expected
index af4540757..a5eecd206 100644
--- a/tests/markups/valid-18.expected
+++ b/tests/markups/valid-18.expected
@@ -5,14 +5,14 @@ Lots of attrs
 
 range 0 13
 0 13 font-desc "Sans Italic 12"
-0 13 foreground #0000ffff0000
-0 13 background #f0f0f0f0f0f0
+0 13 foreground #0000ffff0000ffff
+0 13 background #f0f0f0f0f0f0ffff
 0 13 underline double
-0 13 underline-color #ffff00000000
+0 13 underline-color #ffff00000000ffff
 0 13 gravity south
 0 13 gravity-hint strong
 0 13 strikethrough 1
-0 13 strikethrough-color #00000000ffff
+0 13 strikethrough-color #00000000ffffffff
 0 13 fallback false
 0 13 language de
 range 13 2147483647
diff --git a/tests/markups/valid-19.expected b/tests/markups/valid-19.expected
index 9de3df07b..c9804982a 100644
--- a/tests/markups/valid-19.expected
+++ b/tests/markups/valid-19.expected
@@ -6,7 +6,7 @@ test
 range 0 4
 0 4 family "Times"
 0 4 weight bold
-0 4 foreground #ffff00000000
+0 4 foreground #ffff00000000ffff
 0 4 letter-spacing 1024
 0 4 insert-hyphens true
 range 4 2147483647
diff --git a/tests/markups/valid-2.expected b/tests/markups/valid-2.expected
index 378d49bb4..6cfd1e8ce 100644
--- a/tests/markups/valid-2.expected
+++ b/tests/markups/valid-2.expected
@@ -5,7 +5,7 @@ Blue text is cool!
 
 range 0 9
 0 9 scale 1.728000
-0 9 foreground #00000000ffff
+0 9 foreground #00000000ffffffff
 range 9 13
 range 13 17
 13 17 style italic
diff --git a/tests/markups/valid-3.expected b/tests/markups/valid-3.expected
index 0239dd9b0..f5504aa9b 100644
--- a/tests/markups/valid-3.expected
+++ b/tests/markups/valid-3.expected
@@ -5,14 +5,14 @@ Lots of attrs
 
 range 0 13
 0 13 font-desc "Sans Italic 12"
-0 13 foreground #0000ffff0000
-0 13 background #f0f0f0f0f0f0
+0 13 foreground #0000ffff0000ffff
+0 13 background #f0f0f0f0f0f0ffff
 0 13 underline double
-0 13 underline-color #ffff00000000
+0 13 underline-color #ffff00000000ffff
 0 13 gravity south
 0 13 gravity-hint strong
 0 13 strikethrough 1
-0 13 strikethrough-color #00000000ffff
+0 13 strikethrough-color #00000000ffffffff
 0 13 fallback false
 0 13 language de
 0 13 allow-breaks true
diff --git a/tests/markups/valid-5.expected b/tests/markups/valid-5.expected
index d6e172497..8a3082dcd 100644
--- a/tests/markups/valid-5.expected
+++ b/tests/markups/valid-5.expected
@@ -7,16 +7,16 @@ Text
 ---
 
 range 0 4
-0 4 foreground #222233334444
+0 4 foreground #222233334444ffff
 range 4 5
 range 5 9
-5 9 foreground #222233334444
+5 9 foreground #222233334444ffff
 range 9 10
 range 10 14
-10 14 foreground #222233334444
+10 14 foreground #222233334444ffff
 range 14 15
 range 15 19
-15 19 foreground #222233334444
+15 19 foreground #222233334444ffff
 range 19 2147483647
 
 
diff --git a/tests/markups/valid-6.expected b/tests/markups/valid-6.expected
index 4f1920add..c7bf88962 100644
--- a/tests/markups/valid-6.expected
+++ b/tests/markups/valid-6.expected
@@ -7,19 +7,16 @@ Text
 ---
 
 range 0 4
-0 4 foreground #222233334444
-0 4 foreground-alpha 21845
+0 4 foreground #2222333344445555
 range 4 5
 range 5 9
-5 9 foreground #222233334444
-5 9 foreground-alpha 21845
+5 9 foreground #2222333344445555
 range 9 10
 range 10 14
-10 14 foreground #222233334444
+10 14 foreground #222233334444ffff
 range 14 15
 range 15 19
-15 19 foreground #222233334444
-15 19 foreground-alpha 21845
+15 19 foreground #2222333344445555
 range 19 2147483647
 
 
diff --git a/tests/markups/valid-7.expected b/tests/markups/valid-7.expected
index 71ba77a9e..a3fa498e6 100644
--- a/tests/markups/valid-7.expected
+++ b/tests/markups/valid-7.expected
@@ -5,10 +5,10 @@ Text
 ---
 
 range 0 4
-0 4 underline-color #222233334444
+0 4 underline-color #222233334444ffff
 range 4 5
 range 5 9
-5 9 strikethrough-color #222233334444
+5 9 strikethrough-color #222233334444ffff
 range 9 2147483647
 
 
diff --git a/tests/markups/valid-8.expected b/tests/markups/valid-8.expected
index a4fac1930..398dba9bc 100644
--- a/tests/markups/valid-8.expected
+++ b/tests/markups/valid-8.expected
@@ -15,39 +15,33 @@ range 0 4
 0 4 scale 0.578704
 0 4 variant normal
 0 4 stretch ultra-condensed
-0 4 foreground #00000000ffff
-0 4 foreground-alpha 65535
+0 4 foreground #00000000ffffffff
 range 4 5
 range 5 9
 5 9 scale 0.694444
 5 9 variant small-caps
 5 9 stretch extra-condensed
-5 9 foreground #00000000ffff
-5 9 foreground-alpha 32767
+5 9 foreground #00000000ffff8888
 range 9 10
 range 10 14
 10 14 scale 0.833333
 10 14 stretch condensed
-10 14 background #00000000ffff
-10 14 background-alpha 1
+10 14 background #00000000ffffffff
 range 14 15
 range 15 19
 15 19 scale 1.000000
 15 19 stretch semi-condensed
-15 19 background #00000000ffff
-15 19 background-alpha 21626
+15 19 background #00000000ffff5555
 range 19 20
 range 20 24
 20 24 scale 1.200000
 20 24 stretch normal
-20 24 background #00000000ffff
-20 24 background-alpha 21626
+20 24 background #00000000ffff5555
 range 24 25
 range 25 29
 25 29 scale 1.440000
 25 29 stretch semi-expanded
-25 29 background #00000000ffff
-25 29 background-alpha 43690
+25 29 background #00000000ffffaaaa
 range 29 30
 range 30 34
 30 34 scale 1.728000
diff --git a/tests/markups/valid-8.markup b/tests/markups/valid-8.markup
index d314ed168..dea30a63e 100644
--- a/tests/markups/valid-8.markup
+++ b/tests/markups/valid-8.markup
@@ -1,8 +1,8 @@
-<span foreground="blue" alpha="65535" size="xx-small" variant="normal" stretch="ultracondensed">Text</span>
-<span fgcolor="blue" fgalpha="50%" size="x-small" font_variant="smallcaps" 
font_stretch="extracondensed">Text</span>
-<span background="blue" background_alpha="1" size="small" stretch="condensed">Text</span>
-<span bgcolor="blue" bgalpha="33%" size="medium" stretch="semicondensed">Text</span>
-<span background="blue" bgalpha="33%" font_size="large" stretch="normal">Text</span>
+<span foreground="blue" size="xx-small" variant="normal" stretch="ultracondensed">Text</span>
+<span fgcolor="#00f8" size="x-small" font_variant="smallcaps" font_stretch="extracondensed">Text</span>
+<span background="blue" size="small" stretch="condensed">Text</span>
+<span bgcolor="#00f5" size="medium" stretch="semicondensed">Text</span>
+<span background="#00f5" font_size="large" stretch="normal">Text</span>
 <span background="#0000ffaa" font_size="x-large" stretch="semiexpanded">Text</span>
 <span font_size="xx-large" stretch="expanded">Text</span>
 <span font_size="xx-large" stretch="extraexpanded">Text</span>
diff --git a/tests/testattributes.c b/tests/testattributes.c
index 12060bfa9..5e57d95c5 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -39,8 +39,6 @@ test_attributes_basic (void)
 
   test_copy (pango_attr_language_new (pango_language_from_string ("ja-JP")));
   test_copy (pango_attr_family_new ("Times"));
-  test_copy (pango_attr_foreground_new (&(PangoColor){100, 200, 300}));
-  test_copy (pango_attr_background_new (&(PangoColor){100, 200, 300}));
   test_copy (pango_attr_size_new (1024));
   test_copy (pango_attr_size_new_absolute (1024));
   test_copy (pango_attr_style_new (PANGO_STYLE_ITALIC));
@@ -64,8 +62,6 @@ test_attributes_basic (void)
   test_copy (pango_attr_gravity_new (PANGO_GRAVITY_SOUTH));
   test_copy (pango_attr_gravity_hint_new (PANGO_GRAVITY_HINT_STRONG));
   test_copy (pango_attr_font_features_new ("csc=1"));
-  test_copy (pango_attr_foreground_alpha_new (8000));
-  test_copy (pango_attr_background_alpha_new (8000));
   test_copy (pango_attr_allow_breaks_new (FALSE));
   test_copy (pango_attr_show_new (PANGO_SHOW_SPACES));
   test_copy (pango_attr_insert_hyphens_new (FALSE));
@@ -219,8 +215,8 @@ test_binding_helpers (void)
 
   test_binding (pango_attr_language_new (pango_language_from_string ("ja-JP")));
   test_binding (pango_attr_family_new ("Times"));
-  test_binding (pango_attr_foreground_new (&(PangoColor){100, 200, 300}));
-  test_binding (pango_attr_background_new (&(PangoColor){100, 200, 300}));
+  test_binding (pango_attr_foreground_new (&(PangoColor){100, 200, 300, 400}));
+  test_binding (pango_attr_background_new (&(PangoColor){100, 200, 300, 400}));
   test_binding (pango_attr_size_new (1024));
   test_binding (pango_attr_size_new_absolute (1024));
   test_binding (pango_attr_style_new (PANGO_STYLE_ITALIC));
@@ -244,8 +240,6 @@ test_binding_helpers (void)
   test_binding (pango_attr_gravity_new (PANGO_GRAVITY_SOUTH));
   test_binding (pango_attr_gravity_hint_new (PANGO_GRAVITY_HINT_STRONG));
   test_binding (pango_attr_font_features_new ("csc=1"));
-  test_binding (pango_attr_foreground_alpha_new (8000));
-  test_binding (pango_attr_background_alpha_new (8000));
   test_binding (pango_attr_allow_breaks_new (FALSE));
   test_binding (pango_attr_show_new (PANGO_SHOW_SPACES));
   test_binding (pango_attr_insert_hyphens_new (FALSE));
diff --git a/tests/testcolor.c b/tests/testcolor.c
index b32eb6eeb..26b4412ff 100644
--- a/tests/testcolor.c
+++ b/tests/testcolor.c
@@ -25,92 +25,65 @@
 typedef struct _ColorSpec {
   const gchar *spec;
   gboolean valid;
-  int color_or_alpha;
   guint16 red;
   guint16 green;
   guint16 blue;
   guint16 alpha;
 } ColorSpec;
 
-#define COLOR 1
-#define ALPHA 2
-#define BOTH  3
-
 static void
 test_one_color (ColorSpec *spec)
 {
   PangoColor color;
   gboolean accepted;
-  guint16 alpha;
 
-  if (spec->color_or_alpha & COLOR)
+  accepted = pango_color_parse (&color, spec->spec);
+
+  if (!spec->valid)
     {
-      accepted = pango_color_parse (&color, spec->spec);
-
-      if (!spec->valid)
-        {
-          g_assert_false (accepted);
-        }
-      else
-        {
-          g_assert_true (accepted);
-          g_assert_cmpuint (color.red, ==, spec->red);
-          g_assert_cmpuint (color.green, ==, spec->green);
-          g_assert_cmpuint (color.blue, ==, spec->blue);
-        }
+      g_assert_false (accepted);
     }
-
-  if (spec->color_or_alpha & ALPHA)
+  else
     {
-      accepted = pango_color_parse_with_alpha (&color, &alpha, spec->spec);
-
-      if (!spec->valid)
-        {
-          g_assert_false (accepted);
-        }
-      else
-        {
-          g_assert_true (accepted);
-          g_assert_cmpuint (color.red, ==, spec->red);
-          g_assert_cmpuint (color.green, ==, spec->green);
-          g_assert_cmpuint (color.blue, ==, spec->blue);
-          g_assert_cmpuint (alpha, ==, spec->alpha);
-        }
+      g_assert_true (accepted);
+      g_assert_cmpuint (color.red, ==, spec->red);
+      g_assert_cmpuint (color.green, ==, spec->green);
+      g_assert_cmpuint (color.blue, ==, spec->blue);
+      g_assert_cmpuint (color.alpha, ==, spec->alpha);
     }
 }
 
 ColorSpec specs [] = {
-  { "#abc",          1, BOTH, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
-  { "#aabbcc",       1, BOTH, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
-  { "#aaabbbccc",    1, BOTH, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
-  { "#100100100",    1, BOTH, 0x1001, 0x1001, 0x1001, 0xffff },
-  { "#aaaabbbbcccc", 1, COLOR, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
-  { "#fff",          1, BOTH, 0xffff, 0xffff, 0xffff, 0xffff },
-  { "#ffffff",       1, BOTH, 0xffff, 0xffff, 0xffff, 0xffff },
-  { "#fffffffff",    1, BOTH, 0xffff, 0xffff, 0xffff, 0xffff },
-  { "#ffffffffffff", 1, COLOR, 0xffff, 0xffff, 0xffff, 0xffff },
-  { "#000",          1, BOTH, 0x0000, 0x0000, 0x0000, 0xffff },
-  { "#000000",       1, BOTH, 0x0000, 0x0000, 0x0000, 0xffff },
-  { "#000000000",    1, BOTH, 0x0000, 0x0000, 0x0000, 0xffff },
-  { "#000000000000", 1, COLOR, 0x0000, 0x0000, 0x0000, 0xffff },
-  { "#AAAABBBBCCCC", 1, COLOR, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
-  { "#aa bb cc ",    0, BOTH, 0, 0, 0, 0 },
-  { "#aa bb ccc",    0, BOTH, 0, 0, 0, 0 },
-  { "#ab",           0, BOTH, 0, 0, 0, 0 },
-  { "#aabb",         0, COLOR, 0, 0, 0, 0 },
-  { "#aaabb",        0, BOTH, 0, 0, 0, 0 },
-  { "aaabb",         0, BOTH, 0, 0, 0, 0 },
-  { "",              0, BOTH, 0, 0, 0, 0 },
-  { "#",             0, BOTH, 0, 0, 0, 0 },
-  { "##fff",         0, BOTH, 0, 0, 0, 0 },
-  { "#0000ff+",      0, BOTH, 0, 0, 0, 0 },
-  { "#0000f+",       0, BOTH, 0, 0, 0, 0 },
-  { "#0x00x10x2",    0, BOTH, 0, 0, 0, 0 },
-  { "#abcd",         1, ALPHA, 0xaaaa, 0xbbbb, 0xcccc, 0xdddd },
-  { "#aabbccdd",     1, ALPHA, 0xaaaa, 0xbbbb, 0xcccc, 0xdddd },
-  { "#aaaabbbbccccdddd",
-                     1, ALPHA, 0xaaaa, 0xbbbb, 0xcccc, 0xdddd },
-  { NULL,            0, BOTH, 0, 0, 0, 0 }
+  { "#abc",          1, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
+  { "#aabbcc",       1, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
+  { "#aaabbbccc",    1, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
+  { "#100100100",    1, 0x1001, 0x1001, 0x1001, 0xffff },
+  { "#aaaabbbbcccc", 1, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
+  { "#fff",          1, 0xffff, 0xffff, 0xffff, 0xffff },
+  { "#ffffff",       1, 0xffff, 0xffff, 0xffff, 0xffff },
+  { "#fffffffff",    1, 0xffff, 0xffff, 0xffff, 0xffff },
+  { "#ffffffffffff", 1, 0xffff, 0xffff, 0xffff, 0xffff },
+  { "#000",          1, 0x0000, 0x0000, 0x0000, 0xffff },
+  { "#000000",       1, 0x0000, 0x0000, 0x0000, 0xffff },
+  { "#000000000",    1, 0x0000, 0x0000, 0x0000, 0xffff },
+  { "#000000000000", 1, 0x0000, 0x0000, 0x0000, 0xffff },
+  { "#AAAABBBBCCCC", 1, 0xaaaa, 0xbbbb, 0xcccc, 0xffff },
+  { "#aa bb cc ",    0, 0, 0, 0, 0 },
+  { "#aa bb ccc",    0, 0, 0, 0, 0 },
+  { "#ab",           0, 0, 0, 0, 0 },
+  { "#aabb",         1, 0xaaaa, 0xaaaa, 0xbbbb, 0xbbbb },
+  { "#aaabb",        0, 0, 0, 0, 0 },
+  { "aaabb",         0, 0, 0, 0, 0 },
+  { "",              0, 0, 0, 0, 0 },
+  { "#",             0, 0, 0, 0, 0 },
+  { "##fff",         0, 0, 0, 0, 0 },
+  { "#0000ff+",      0, 0, 0, 0, 0 },
+  { "#0000f+",       0, 0, 0, 0, 0 },
+  { "#0x00x10x2",    0, 0, 0, 0, 0 },
+  { "#abcd",         1, 0xaaaa, 0xbbbb, 0xcccc, 0xdddd },
+  { "#aabbccdd",     1, 0xaaaa, 0xbbbb, 0xcccc, 0xdddd },
+  { "#aaaabbbbccccdddd", 1, 0xaaaa, 0xbbbb, 0xcccc, 0xdddd },
+  { NULL,            0, 0, 0, 0, 0 }
 };
 
 static void
@@ -125,7 +98,7 @@ test_color (void)
 static void
 test_color_copy (void)
 {
-  PangoColor orig = { 0, 200, 5000 };
+  PangoColor orig = { 0, 200, 5000, 666 };
   PangoColor *copy;
 
   copy = pango_color_copy (&orig);
@@ -133,6 +106,7 @@ test_color_copy (void)
   g_assert_cmpint (orig.red, ==, copy->red);
   g_assert_cmpint (orig.green, ==, copy->green);
   g_assert_cmpint (orig.blue, ==, copy->blue);
+  g_assert_cmpint (orig.alpha, ==, copy->alpha);
 
   pango_color_free (copy);
 }
@@ -140,12 +114,12 @@ test_color_copy (void)
 static void
 test_color_serialize (void)
 {
-  PangoColor orig = { 0, 200, 5000 };
+  PangoColor orig = { 0, 200, 5000, 666 };
   char *string;
 
   string = pango_color_to_string (&orig);
 
-  g_assert_cmpstr (string, ==, "#000000c81388");
+  g_assert_cmpstr (string, ==, "#000000c81388029a");
 
   g_free (string);
 }
diff --git a/tests/testserialize.c b/tests/testserialize.c
index cd85add58..4c76b2399 100644
--- a/tests/testserialize.c
+++ b/tests/testserialize.c
@@ -43,8 +43,8 @@ test_serialize_attr_list (void)
   };
   const char *roundtripped[] = {
     "5 16 style italic",
-    "0 10 foreground #ffff00000000\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
-    "0 10 foreground #ffff00000000\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
+    "0 10 foreground #ffff00000000ffff\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
+    "0 10 foreground #ffff00000000ffff\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
     "0 10 fallback false\n5 15 weight semilight",
     "0 100 font-desc \"Cantarell,Sans Ultra-Light Italic 64\"\n10 11 weight thin",
     "0 4294967295 size 10",
@@ -237,18 +237,18 @@ test_serialize_layout_valid (void)
     "    {\n"
     "      \"end\" : 4,\n"
     "      \"type\" : \"foreground\",\n"
-    "      \"value\" : \"#ffff00000000\"\n"
+    "      \"value\" : \"#ffff00000000ffff\"\n"
     "    },\n"
     "    {\n"
     "      \"start\" : 5,\n"
     "      \"end\" : 8,\n"
     "      \"type\" : \"foreground\",\n"
-    "      \"value\" : \"#000080800000\"\n"
+    "      \"value\" : \"#000080800000ffff\"\n"
     "    },\n"
     "    {\n"
     "      \"start\" : 14,\n"
     "      \"type\" : \"foreground\",\n"
-    "      \"value\" : \"#ffff0000ffff\"\n"
+    "      \"value\" : \"#ffff0000ffffffff\"\n"
     "    }\n"
     "  ],\n"
     "  \"font\" : \"Sans Bold 32\",\n"


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