[pango/pango2: 144/201] Drop shape attributes




commit 05c680703b2a74b4f290bc28025f5374b9dd067f
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 7 20:01:38 2022 -0400

    Drop shape attributes
    
    Shape attributes don't fit well with the other
    attributes, and user fonts are a better way of
    doing custom glyphs.

 pango/pango-attributes.c   | 159 ---------------------------------------------
 pango/pango-attributes.h   |  37 -----------
 pango/pango-impl-utils.h   |  15 -----
 pango/pango-item-private.h |   3 -
 pango/pango-item.c         |   9 ---
 pango/pango-line-breaker.c |  19 ++----
 pango/pango-renderer.c     |  87 +++----------------------
 pango/pango-renderer.h     |   7 --
 pango/pango-run.c          |   7 +-
 pango/pango-utils.c        |  76 ----------------------
 pango/pangocairo-context.c |  87 -------------------------
 pango/pangocairo-render.c  |  38 -----------
 pango/pangocairo.h         |  28 --------
 pango/serializer.c         |   9 ---
 tests/meson.build          |   1 -
 tests/test-itemize.c       |   1 -
 tests/testattributes.c     |  11 +---
 17 files changed, 17 insertions(+), 577 deletions(-)
---
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 9b8dcb8f..2bebcf59 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -478,51 +478,6 @@ pango_attr_font_desc_equal (const PangoAttribute *attr1,
          pango_font_description_equal (desc_attr1->desc, desc_attr2->desc);
 }
 /* }}} */
-/* {{{ Shape attribute */
-static PangoAttribute *
-pango_attr_shape_copy (const PangoAttribute *attr)
-{
-  const PangoAttrShape *shape_attr = (PangoAttrShape *)attr;
-  gpointer data;
-
-  if (shape_attr->copy_func)
-    data = shape_attr->copy_func (shape_attr->data);
-  else
-    data = shape_attr->data;
-
-  return pango_attr_shape_new_with_data (&shape_attr->ink_rect, &shape_attr->logical_rect,
-                                         data, shape_attr->copy_func, shape_attr->destroy_func);
-}
-
-static void
-pango_attr_shape_destroy (PangoAttribute *attr)
-{
-  PangoAttrShape *shape_attr = (PangoAttrShape *)attr;
-
-  if (shape_attr->destroy_func)
-    shape_attr->destroy_func (shape_attr->data);
-
-  g_slice_free (PangoAttrShape, shape_attr);
-}
-
-static gboolean
-pango_attr_shape_equal (const PangoAttribute *attr1,
-                        const PangoAttribute *attr2)
-{
-  const PangoAttrShape *shape_attr1 = (const PangoAttrShape *)attr1;
-  const PangoAttrShape *shape_attr2 = (const PangoAttrShape *)attr2;
-
-  return (shape_attr1->logical_rect.x == shape_attr2->logical_rect.x &&
-          shape_attr1->logical_rect.y == shape_attr2->logical_rect.y &&
-          shape_attr1->logical_rect.width == shape_attr2->logical_rect.width &&
-          shape_attr1->logical_rect.height == shape_attr2->logical_rect.height &&
-          shape_attr1->ink_rect.x == shape_attr2->ink_rect.x &&
-          shape_attr1->ink_rect.y == shape_attr2->ink_rect.y &&
-          shape_attr1->ink_rect.width == shape_attr2->ink_rect.width &&
-          shape_attr1->ink_rect.height == shape_attr2->ink_rect.height &&
-          shape_attr1->data == shape_attr2->data);
-}
-/* }}} */
 /* }}} */
 /* {{{ Private API */
 
@@ -549,7 +504,6 @@ pango_attribute_affects_itemization (PangoAttribute *attr,
     case PANGO_ATTR_FONT_SCALE:
     /* These need to be constant across runs */
     case PANGO_ATTR_LETTER_SPACING:
-    case PANGO_ATTR_SHAPE:
     case PANGO_ATTR_RISE:
     case PANGO_ATTR_BASELINE_SHIFT:
     case PANGO_ATTR_LINE_HEIGHT:
@@ -1130,86 +1084,6 @@ pango_attr_letter_spacing_new (int letter_spacing)
   return pango_attr_int_new (&klass, letter_spacing);
 }
 
-/**
- * pango_attr_shape_new_with_data:
- * @ink_rect: ink rectangle to assign to each character
- * @logical_rect: logical rectangle to assign to each character
- * @data: user data pointer
- * @copy_func: (nullable): function to copy @data when the
- *   attribute is copied. If %NULL, @data is simply copied
- *   as a pointer
- * @destroy_func: (nullable): function to free @data when the
- *   attribute is freed
- *
- * Creates a new shape attribute.
- *
- * Like [func Pango AttrShape new], but a user data pointer
- * is also provided; this pointer can be accessed when later
- * rendering the glyph.
- *
- * Return value: (transfer full): the newly allocated
- *   `PangoAttribute`, which should be freed with
- *   [method@Pango.Attribute.destroy]
- *
- * Since: 1.8
- */
-PangoAttribute *
-pango_attr_shape_new_with_data (const PangoRectangle  *ink_rect,
-                                const PangoRectangle  *logical_rect,
-                                gpointer               data,
-                                PangoAttrDataCopyFunc  copy_func,
-                                GDestroyNotify         destroy_func)
-{
-  static const PangoAttrClass klass = {
-    PANGO_ATTR_SHAPE,
-    pango_attr_shape_copy,
-    pango_attr_shape_destroy,
-    pango_attr_shape_equal
-  };
-
-  PangoAttrShape *result;
-
-  g_return_val_if_fail (ink_rect != NULL, NULL);
-  g_return_val_if_fail (logical_rect != NULL, NULL);
-
-  result = g_slice_new (PangoAttrShape);
-  pango_attribute_init (&result->attr, &klass);
-  result->ink_rect = *ink_rect;
-  result->logical_rect = *logical_rect;
-  result->data = data;
-  result->copy_func = copy_func;
-  result->destroy_func =  destroy_func;
-
-  return (PangoAttribute *)result;
-}
-
-/**
- * pango_attr_shape_new:
- * @ink_rect: ink rectangle to assign to each character
- * @logical_rect: logical rectangle to assign to each character
- *
- * Create a new shape attribute.
- *
- * A shape is used to impose a particular ink and logical
- * rectangle on the result of shaping a particular glyph.
- * This might be used, for instance, for embedding a picture
- * or a widget inside a `PangoLayout`.
- *
- * Return value: (transfer full): the newly allocated
- *   `PangoAttribute`, which should be freed with
- *   [method@Pango.Attribute.destroy]
- */
-PangoAttribute *
-pango_attr_shape_new (const PangoRectangle *ink_rect,
-                      const PangoRectangle *logical_rect)
-{
-  g_return_val_if_fail (ink_rect != NULL, NULL);
-  g_return_val_if_fail (logical_rect != NULL, NULL);
-
-  return pango_attr_shape_new_with_data (ink_rect, logical_rect,
-                                         NULL, NULL, NULL);
-}
-
 /**
  * pango_attr_gravity_new:
  * @gravity: the gravity value; should not be %PANGO_GRAVITY_AUTO
@@ -1898,32 +1772,6 @@ pango_attribute_as_language (PangoAttribute *attr)
     }
 }
 
-/**
- * pango_attribute_as_shape:
- * @attr: A `PangoAttribute` representing a shape
- *
- * Returns the attribute cast to `PangoAttrShape`.
- *
- * This is mainly useful for language bindings.
- *
- * Returns: (nullable) (transfer none): The attribute as `PangoAttrShape`,
- *   or %NULL if it's not a shape attribute
- *
- * Since: 1.50
- */
-PangoAttrShape *
-pango_attribute_as_shape (PangoAttribute *attr)
-{
-  switch ((int)attr->klass->type)
-    {
-    case PANGO_ATTR_SHAPE:
-      return (PangoAttrShape *)attr;
-
-    default:
-      return NULL;
-    }
-}
-
 /* }}} */
 /* {{{ Attribute List */
 
@@ -2724,7 +2572,6 @@ attr_print (GString        *str,
   PangoAttrFloat *flt;
   PangoAttrFontDesc *font;
   PangoAttrColor *color;
-  PangoAttrShape *shape;
   PangoAttrSize *size;
   PangoAttrFontFeatures *features;
 
@@ -2773,8 +2620,6 @@ attr_print (GString        *str,
       g_string_append_printf (str, " %s", s);
       g_free (s);
     }
-  else if ((shape = pango_attribute_as_shape (attr)) != NULL)
-    g_string_append (str, "shape"); /* FIXME */
   else if ((size = pango_attribute_as_size (attr)) != NULL)
     g_string_append_printf (str, " %d", size->size);
   else if ((features = pango_attribute_as_font_features (attr)) != NULL)
@@ -3063,10 +2908,6 @@ pango_attr_list_from_string (const char *text)
           INT_ATTR(rise, int);
           break;
 
-        case PANGO_ATTR_SHAPE:
-          endp = (char *)p + strcspn (p, ",\n");
-          continue; /* FIXME */
-
         case PANGO_ATTR_SCALE:
           FLOAT_ATTR(scale);
           break;
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index c16649c5..0b8bfc31 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -39,7 +39,6 @@ typedef struct _PangoAttrSize         PangoAttrSize;
 typedef struct _PangoAttrFloat        PangoAttrFloat;
 typedef struct _PangoAttrColor        PangoAttrColor;
 typedef struct _PangoAttrFontDesc     PangoAttrFontDesc;
-typedef struct _PangoAttrShape        PangoAttrShape;
 typedef struct _PangoAttrFontFeatures PangoAttrFontFeatures;
 
 /**
@@ -58,7 +57,6 @@ typedef struct _PangoAttrFontFeatures PangoAttrFontFeatures;
  * @PANGO_ATTR_UNDERLINE: whether the text has an underline ([struct@Pango.AttrInt])
  * @PANGO_ATTR_STRIKETHROUGH: whether the text is struck-through ([struct@Pango.AttrInt])
  * @PANGO_ATTR_RISE: baseline displacement ([struct@Pango.AttrInt])
- * @PANGO_ATTR_SHAPE: shape ([struct@Pango.AttrShape])
  * @PANGO_ATTR_SCALE: font size scale factor ([struct@Pango.AttrFloat])
  * @PANGO_ATTR_FALLBACK: whether fallback is enabled ([struct@Pango.AttrInt])
  * @PANGO_ATTR_LETTER_SPACING: letter spacing ([struct@PangoAttrInt])
@@ -108,7 +106,6 @@ typedef enum
   PANGO_ATTR_UNDERLINE,         /* PangoAttrInt */
   PANGO_ATTR_STRIKETHROUGH,     /* PangoAttrInt */
   PANGO_ATTR_RISE,              /* PangoAttrInt */
-  PANGO_ATTR_SHAPE,             /* PangoAttrShape */
   PANGO_ATTR_SCALE,             /* PangoAttrFloat */
   PANGO_ATTR_FALLBACK,          /* PangoAttrInt */
   PANGO_ATTR_LETTER_SPACING,    /* PangoAttrInt */
@@ -449,29 +446,6 @@ struct _PangoAttrSize
   guint absolute : 1;
 };
 
-/**
- * PangoAttrShape:
- * @attr: the common portion of the attribute
- * @ink_rect: the ink rectangle to restrict to
- * @logical_rect: the logical rectangle to restrict to
- * @data: user data set (see [func@Pango.AttrShape.new_with_data])
- * @copy_func: copy function for the user data
- * @destroy_func: destroy function for the user data
- *
- * The `PangoAttrShape` structure is used to represent attributes which
- * impose shape restrictions.
- */
-struct _PangoAttrShape
-{
-  PangoAttribute attr;
-  PangoRectangle ink_rect;
-  PangoRectangle logical_rect;
-
-  gpointer              data;
-  PangoAttrDataCopyFunc copy_func;
-  GDestroyNotify        destroy_func;
-};
-
 /**
  * PangoAttrFontDesc:
  * @attr: the common portion of the attribute
@@ -571,15 +545,6 @@ PANGO_AVAILABLE_IN_1_4
 PangoAttribute *        pango_attr_fallback_new                 (gboolean                    
enable_fallback);
 PANGO_AVAILABLE_IN_1_6
 PangoAttribute *        pango_attr_letter_spacing_new           (int                         letter_spacing);
-PANGO_AVAILABLE_IN_ALL
-PangoAttribute *        pango_attr_shape_new                    (const PangoRectangle        *ink_rect,
-                                                                 const PangoRectangle        *logical_rect);
-PANGO_AVAILABLE_IN_1_8
-PangoAttribute *        pango_attr_shape_new_with_data          (const PangoRectangle        *ink_rect,
-                                                                 const PangoRectangle        *logical_rect,
-                                                                 gpointer                     data,
-                                                                 PangoAttrDataCopyFunc        copy_func,
-                                                                 GDestroyNotify               destroy_func);
 PANGO_AVAILABLE_IN_1_16
 PangoAttribute *        pango_attr_gravity_new                  (PangoGravity                 gravity);
 PANGO_AVAILABLE_IN_1_16
@@ -634,8 +599,6 @@ PangoAttrColor        * pango_attribute_as_color                (PangoAttribute
 PANGO_AVAILABLE_IN_1_50
 PangoAttrFontDesc     * pango_attribute_as_font_desc            (PangoAttribute              *attr);
 PANGO_AVAILABLE_IN_1_50
-PangoAttrShape        * pango_attribute_as_shape                (PangoAttribute              *attr);
-PANGO_AVAILABLE_IN_1_50
 PangoAttrFontFeatures * pango_attribute_as_font_features        (PangoAttribute              *attr);
 
 /* Attribute lists */
diff --git a/pango/pango-impl-utils.h b/pango/pango-impl-utils.h
index 55c743df..cd125afe 100644
--- a/pango/pango-impl-utils.h
+++ b/pango/pango-impl-utils.h
@@ -33,21 +33,6 @@ G_BEGIN_DECLS
 /* String interning for static strings */
 #define I_(string) g_intern_static_string (string)
 
-
-/* Some functions for handling PANGO_ATTR_SHAPE */
-void _pango_shape_shape (const char       *text,
-                        unsigned int      n_chars,
-                        PangoRectangle   *shape_ink,
-                        PangoRectangle   *shape_logical,
-                        PangoGlyphString *glyphs);
-
-void _pango_shape_get_extents (gint              n_chars,
-                              PangoRectangle   *shape_ink,
-                              PangoRectangle   *shape_logical,
-                              PangoRectangle   *ink_rect,
-                              PangoRectangle   *logical_rect);
-
-
 /* We define these functions static here because we don't want to add public API
  * for them (if anything, it belongs to glib, but glib found it trivial enough
  * not to add API for).  At some point metrics calculations will be
diff --git a/pango/pango-item-private.h b/pango/pango-item-private.h
index 78c3e4a7..6705e19c 100644
--- a/pango/pango-item-private.h
+++ b/pango/pango-item-private.h
@@ -65,13 +65,10 @@ struct _ItemProperties
   guint oline_single        : 1;
   guint showing_space       : 1;
   guint no_paragraph_break  : 1;
-  guint shape_set           : 1;
   int letter_spacing;
   int line_spacing;
   int absolute_line_height;
   double line_height;
-  PangoRectangle *shape_ink_rect;
-  PangoRectangle *shape_logical_rect;
 };
 
 void               pango_item_get_properties          (PangoItem        *item,
diff --git a/pango/pango-item.c b/pango/pango-item.c
index 2a68f3be..cbf21f42 100644
--- a/pango/pango-item.c
+++ b/pango/pango-item.c
@@ -385,10 +385,7 @@ pango_item_get_properties (PangoItem      *item,
   properties->strikethrough = FALSE;
   properties->showing_space = FALSE;
   properties->no_paragraph_break = FALSE;
-  properties->shape_set = FALSE;
   properties->letter_spacing = 0;
-  properties->shape_ink_rect = NULL;
-  properties->shape_logical_rect = NULL;
   properties->line_height = 0.0;
   properties->absolute_line_height = 0;
   properties->line_spacing = 0;
@@ -444,12 +441,6 @@ pango_item_get_properties (PangoItem      *item,
           properties->letter_spacing = ((PangoAttrInt *)attr)->value;
           break;
 
-        case PANGO_ATTR_SHAPE:
-          properties->shape_set = TRUE;
-          properties->shape_logical_rect = &((PangoAttrShape *)attr)->logical_rect;
-          properties->shape_ink_rect = &((PangoAttrShape *)attr)->ink_rect;
-          break;
-
         case PANGO_ATTR_LINE_HEIGHT:
           properties->line_height = ((PangoAttrFloat *)attr)->value;
           break;
diff --git a/pango/pango-line-breaker.c b/pango/pango-line-breaker.c
index 758246d9..1ad180af 100644
--- a/pango/pango-line-breaker.c
+++ b/pango/pango-line-breaker.c
@@ -864,16 +864,11 @@ shape_run (PangoLineBreaker *self,
       if (pango_context_get_round_glyph_positions (self->context))
         shape_flags |= PANGO_SHAPE_ROUND_POSITIONS;
 
-      if (self->properties.shape_set)
-        _pango_shape_shape (self->data->text + item->offset, item->num_chars,
-                            self->properties.shape_ink_rect, self->properties.shape_logical_rect,
-                            glyphs);
-      else
-        pango_shape_item (item,
-                          self->data->text, self->data->length,
-                          self->data->log_attrs + self->start_offset,
-                          glyphs,
-                          shape_flags);
+      pango_shape_item (item,
+                        self->data->text, self->data->length,
+                        self->data->log_attrs + self->start_offset,
+                        glyphs,
+                        shape_flags);
 
       if (self->properties.letter_spacing)
         {
@@ -1186,7 +1181,6 @@ process_item (PangoLineBreaker *self,
               gboolean         is_last_item)
 {
   PangoItem *item = self->items->data;
-  gboolean shape_set = FALSE;
   int width;
   int extra_width;
   int orig_extra_width;
@@ -1503,9 +1497,6 @@ retry_break:
 
           self->log_widths_offset += break_num_chars;
 
-          /* Shaped items should never be broken */
-          g_assert (!shape_set);
-
           DEBUG1 ("some-fit '%.*s', remaining %d",
                   new_item->length, self->data->text + new_item->offset,
                   self->remaining_width);
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index da802c3e..8cdbec43 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -455,55 +455,6 @@ add_strikethrough (PangoRenderer    *renderer,
     }
 }
 
-static void
-get_item_properties (PangoItem       *item,
-                     PangoAttrShape **shape_attr)
-{
-  GSList *l;
-
-  if (shape_attr)
-    *shape_attr = NULL;
-
-  for (l = item->analysis.extra_attrs; l; l = l->next)
-    {
-      PangoAttribute *attr = l->data;
-
-      switch ((int) attr->klass->type)
-        {
-        case PANGO_ATTR_SHAPE:
-          if (shape_attr)
-            *shape_attr = (PangoAttrShape *)attr;
-          break;
-
-        default:
-          break;
-        }
-    }
-}
-
-static void
-draw_shaped_glyphs (PangoRenderer    *renderer,
-                    PangoGlyphString *glyphs,
-                    PangoAttrShape   *attr,
-                    int               x,
-                    int               y)
-{
-  PangoRendererClass *class = PANGO_RENDERER_GET_CLASS (renderer);
-  int i;
-
-  if (!class->draw_shape)
-    return;
-
-  for (i = 0; i < glyphs->num_glyphs; i++)
-    {
-      PangoGlyphInfo *gi = &glyphs->glyphs[i];
-
-      class->draw_shape (renderer, attr, x, y);
-
-      x += gi->geometry.width;
-    }
-}
-
 static void pango_renderer_draw_runs (PangoRenderer *renderer,
                                       GSList        *runs,
                                       const char    *text,
@@ -622,7 +573,6 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
       PangoGlyphItem *glyph_item = l->data;
       PangoItem *item = glyph_item->item;
       PangoGlyphString *glyphs = glyph_item->glyphs;
-      PangoAttrShape *shape_attr;
       PangoRectangle ink_rect, *ink = NULL;
       PangoRectangle logical_rect, *logical = NULL;
       int y_off;
@@ -632,35 +582,19 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
 
       pango_renderer_prepare_run (renderer, run);
 
-      get_item_properties (item, &shape_attr);
-
-      if (shape_attr)
+      if (renderer->underline != PANGO_UNDERLINE_NONE ||
+          renderer->priv->overline != PANGO_OVERLINE_NONE ||
+          renderer->strikethrough)
         {
           ink = &ink_rect;
           logical = &logical_rect;
-          _pango_shape_get_extents (glyphs->num_glyphs,
-                                    &shape_attr->ink_rect,
-                                    &shape_attr->logical_rect,
-                                    ink,
-                                    logical);
-          glyph_string_width = logical->width;
         }
+      if (G_UNLIKELY (ink || logical))
+        pango_glyph_string_extents (glyphs, item->analysis.font, ink, logical);
+      if (logical)
+        glyph_string_width = logical_rect.width;
       else
-        {
-          if (renderer->underline != PANGO_UNDERLINE_NONE ||
-              renderer->priv->overline != PANGO_OVERLINE_NONE ||
-              renderer->strikethrough)
-            {
-              ink = &ink_rect;
-              logical = &logical_rect;
-            }
-          if (G_UNLIKELY (ink || logical))
-            pango_glyph_string_extents (glyphs, item->analysis.font, ink, logical);
-          if (logical)
-            glyph_string_width = logical_rect.width;
-          else
-            glyph_string_width = pango_glyph_string_get_width (glyphs);
-        }
+        glyph_string_width = pango_glyph_string_get_width (glyphs);
 
       renderer->priv->line_state->logical_rect_end = x + x_off + glyph_string_width;
 
@@ -696,10 +630,7 @@ pango_renderer_draw_runs (PangoRenderer *renderer,
                                          overall_rect.height);
         }
 
-      if (shape_attr)
-        draw_shaped_glyphs (renderer, glyphs, shape_attr, x + x_off, y - y_off);
-      else
-        pango_renderer_draw_glyph_item (renderer, text, glyph_item, x + x_off, y - y_off);
+      pango_renderer_draw_glyph_item (renderer, text, glyph_item, x + x_off, y - y_off);
 
       if (renderer->underline != PANGO_UNDERLINE_NONE ||
           renderer->priv->overline != PANGO_OVERLINE_NONE ||
diff --git a/pango/pango-renderer.h b/pango/pango-renderer.h
index 0f5d0d3f..ede8d4f3 100644
--- a/pango/pango-renderer.h
+++ b/pango/pango-renderer.h
@@ -100,9 +100,6 @@ struct _PangoRenderer
  * @draw_error_underline: draws a squiggly line that approximately
  * covers the given rectangle in the style of an underline used to
  * indicate a spelling error.
- * @draw_shape: draw content for a glyph shaped with `PangoAttrShape`
- *   @x, @y are the coordinates of the left edge of the baseline,
- *   in user coordinates.
  * @draw_trapezoid: draws a trapezoidal filled area
  * @draw_glyph: draws a single glyph
  * @part_changed: do renderer specific processing when rendering
@@ -155,10 +152,6 @@ struct _PangoRendererClass
                                 int               y,
                                 int               width,
                                 int               height);
-  void (*draw_shape)           (PangoRenderer    *renderer,
-                                PangoAttrShape   *attr,
-                                int               x,
-                                int               y);
 
   void (*draw_trapezoid)       (PangoRenderer    *renderer,
                                 PangoRenderPart   part,
diff --git a/pango/pango-run.c b/pango/pango-run.c
index a011395d..7fba066c 100644
--- a/pango/pango-run.c
+++ b/pango/pango-run.c
@@ -89,13 +89,8 @@ pango_run_get_extents (PangoRun         *run,
   if (!logical_rect && (has_underline || has_overline || properties.strikethrough))
     logical_rect = &logical;
 
-  if (properties.shape_set)
-    _pango_shape_get_extents (glyph_item->item->num_chars,
-                              properties.shape_ink_rect, properties.shape_logical_rect,
+  pango_glyph_string_extents (glyph_item->glyphs, glyph_item->item->analysis.font,
                               ink_rect, logical_rect);
-  else
-    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))
     {
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index 80b18061..126bb41b 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -509,82 +509,6 @@ pango_extents_to_pixels (PangoRectangle *inclusive,
     }
 }
 
-
-
-
-
-/*********************************************************
- * Some internal functions for handling PANGO_ATTR_SHAPE *
- ********************************************************/
-
-void
-_pango_shape_shape (const char       *text,
-                   unsigned int      n_chars,
-                   PangoRectangle   *shape_ink G_GNUC_UNUSED,
-                   PangoRectangle   *shape_logical,
-                   PangoGlyphString *glyphs)
-{
-  unsigned int i;
-  const char *p;
-
-  pango_glyph_string_set_size (glyphs, n_chars);
-
-  for (i=0, p = text; i < n_chars; i++, p = g_utf8_next_char (p))
-    {
-      glyphs->glyphs[i].glyph = PANGO_GLYPH_EMPTY;
-      glyphs->glyphs[i].geometry.x_offset = 0;
-      glyphs->glyphs[i].geometry.y_offset = 0;
-      glyphs->glyphs[i].geometry.width = shape_logical->width;
-      glyphs->glyphs[i].attr.is_cluster_start = 1;
-
-      glyphs->log_clusters[i] = p - text;
-    }
-}
-
-void
-_pango_shape_get_extents (gint              n_chars,
-                         PangoRectangle   *shape_ink,
-                         PangoRectangle   *shape_logical,
-                         PangoRectangle   *ink_rect,
-                         PangoRectangle   *logical_rect)
-{
-  if (n_chars > 0)
-    {
-      if (ink_rect)
-       {
-         ink_rect->x = MIN (shape_ink->x, shape_ink->x + shape_logical->width * (n_chars - 1));
-         ink_rect->width = MAX (shape_ink->width, shape_ink->width + shape_logical->width * (n_chars - 1));
-         ink_rect->y = shape_ink->y;
-         ink_rect->height = shape_ink->height;
-       }
-      if (logical_rect)
-       {
-         logical_rect->x = MIN (shape_logical->x, shape_logical->x + shape_logical->width * (n_chars - 1));
-         logical_rect->width = MAX (shape_logical->width, shape_logical->width + shape_logical->width * 
(n_chars - 1));
-         logical_rect->y = shape_logical->y;
-         logical_rect->height = shape_logical->height;
-       }
-    }
-  else
-    {
-      if (ink_rect)
-       {
-         ink_rect->x = 0;
-         ink_rect->y = 0;
-         ink_rect->width = 0;
-         ink_rect->height = 0;
-       }
-
-      if (logical_rect)
-       {
-         logical_rect->x = 0;
-         logical_rect->y = 0;
-         logical_rect->width = 0;
-         logical_rect->height = 0;
-       }
-    }
-}
-
 /**
  * pango_find_paragraph_boundary:
  * @text: UTF-8 text
diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c
index b1d6a03e..e0b9ebef 100644
--- a/pango/pangocairo-context.c
+++ b/pango/pangocairo-context.c
@@ -37,10 +37,6 @@ struct _PangoCairoContextInfo
   cairo_font_options_t *set_options;
   cairo_font_options_t *surface_options;
   cairo_font_options_t *merged_options;
-
-  PangoCairoShapeRendererFunc shape_renderer_func;
-  gpointer                    shape_renderer_data;
-  GDestroyNotify              shape_renderer_notify;
 };
 
 static void
@@ -53,9 +49,6 @@ free_context_info (PangoCairoContextInfo *info)
   if (info->merged_options)
     cairo_font_options_destroy (info->merged_options);
 
-  if (info->shape_renderer_notify)
-    info->shape_renderer_notify (info->shape_renderer_data);
-
   g_slice_free (PangoCairoContextInfo, info);
 }
 
@@ -341,86 +334,6 @@ _pango_cairo_context_get_merged_font_options (PangoContext *context)
   return info->merged_options;
 }
 
-/**
- * pango_cairo_context_set_shape_renderer:
- * @context: a `PangoContext`, from a pangocairo font map
- * @func: (nullable): Callback function for rendering attributes of
- *   type %PANGO_ATTR_SHAPE, or %NULL to disable shape rendering.
- * @data: (nullable): User data that will be passed to @func.
- * @dnotify: (nullable): Callback that will be called when the
- *   context is freed to release @data
- *
- * Sets callback function for context to use for rendering attributes
- * of type %PANGO_ATTR_SHAPE.
- *
- * See `PangoCairoShapeRendererFunc` for details.
- *
- * Since: 1.18
- */
-void
-pango_cairo_context_set_shape_renderer (PangoContext                *context,
-                                       PangoCairoShapeRendererFunc  func,
-                                       gpointer                     data,
-                                       GDestroyNotify               dnotify)
-{
-  PangoCairoContextInfo *info;
-
-  g_return_if_fail (PANGO_IS_CONTEXT (context));
-
-  info  = get_context_info (context, TRUE);
-
-  if (info->shape_renderer_notify)
-    info->shape_renderer_notify (info->shape_renderer_data);
-
-  info->shape_renderer_func   = func;
-  info->shape_renderer_data   = data;
-  info->shape_renderer_notify = dnotify;
-}
-
-/**
- * pango_cairo_context_get_shape_renderer: (skip)
- * @context: a `PangoContext`, from a pangocairo font map
- * @data: Pointer to `gpointer` to return user data
- *
- * Sets callback function for context to use for rendering attributes
- * of type %PANGO_ATTR_SHAPE.
- *
- * See `PangoCairoShapeRendererFunc` for details.
- *
- * Retrieves callback function and associated user data for rendering
- * attributes of type %PANGO_ATTR_SHAPE as set by
- * [func@PangoCairo.context_set_shape_renderer], if any.
- *
- * Return value: (transfer none) (nullable): the shape rendering callback
- *   previously set on the context, or %NULL if no shape rendering callback
- *   have been set.
- *
- * Since: 1.18
- */
-PangoCairoShapeRendererFunc
-pango_cairo_context_get_shape_renderer (PangoContext *context,
-                                        gpointer     *data)
-{
-  PangoCairoContextInfo *info;
-
-  g_return_val_if_fail (PANGO_IS_CONTEXT (context), NULL);
-
-  info = get_context_info (context, FALSE);
-
-  if (info)
-    {
-      if (data)
-        *data = info->shape_renderer_data;
-      return info->shape_renderer_func;
-    }
-  else
-    {
-      if (data)
-        *data = NULL;
-      return NULL;
-    }
-}
-
 /**
  * pango_cairo_create_context:
  * @cr: a Cairo context
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index 7841033c..4deb80be 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -774,43 +774,6 @@ pango_cairo_renderer_draw_error_underline (PangoRenderer *renderer,
     }
 }
 
-static void
-pango_cairo_renderer_draw_shape (PangoRenderer  *renderer,
-                                 PangoAttrShape *attr,
-                                 int             x,
-                                 int             y)
-{
-  PangoCairoRenderer *crenderer = (PangoCairoRenderer *) (renderer);
-  cairo_t *cr = crenderer->cr;
-  PangoContext *context;
-  PangoCairoShapeRendererFunc shape_renderer;
-  gpointer shape_renderer_data;
-  double base_x, base_y;
-
-  context = pango_renderer_get_context (renderer);
-
-  if (!context)
-    return;
-
-  shape_renderer = pango_cairo_context_get_shape_renderer (context, &shape_renderer_data);
-
-  if (!shape_renderer)
-    return;
-
-  base_x = crenderer->x_offset + (double)x / PANGO_SCALE;
-  base_y = crenderer->y_offset + (double)y / PANGO_SCALE;
-
-  cairo_save (cr);
-  if (!crenderer->do_path)
-    set_color (crenderer, PANGO_RENDER_PART_FOREGROUND);
-
-  cairo_move_to (cr, base_x, base_y);
-
-  shape_renderer (cr, attr, crenderer->do_path, shape_renderer_data);
-
-  cairo_restore (cr);
-}
-
 static void
 pango_cairo_renderer_init (PangoCairoRenderer *renderer G_GNUC_UNUSED)
 {
@@ -826,7 +789,6 @@ pango_cairo_renderer_class_init (PangoCairoRendererClass *klass)
   renderer_class->draw_rectangle = pango_cairo_renderer_draw_rectangle;
   renderer_class->draw_trapezoid = pango_cairo_renderer_draw_trapezoid;
   renderer_class->draw_error_underline = pango_cairo_renderer_draw_error_underline;
-  renderer_class->draw_shape = pango_cairo_renderer_draw_shape;
 }
 
 static PangoCairoRenderer *cached_renderer = NULL; /* MT-safe */
diff --git a/pango/pangocairo.h b/pango/pangocairo.h
index b32cf465..385e1228 100644
--- a/pango/pangocairo.h
+++ b/pango/pangocairo.h
@@ -77,25 +77,6 @@ typedef struct _PangoCairoFontMap        PangoCairoFontMap;
 #define PANGO_IS_CAIRO_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_CAIRO_FONT_MAP))
 #endif
 
-/**
- * PangoCairoShapeRendererFunc:
- * @cr: a Cairo context with current point set to where the shape should
- * be rendered
- * @attr: the %PANGO_ATTR_SHAPE to render
- * @do_path: whether only the shape path should be appended to current
- * path of @cr and no filling/stroking done.  This will be set
- * to %TRUE when called from pango_cairo_layout_path() and
- * pango_cairo_layout_line_path() rendering functions.
- * @data: (closure): user data passed to pango_cairo_context_set_shape_renderer()
- *
- * Function type for rendering attributes of type %PANGO_ATTR_SHAPE
- * with Pango's Cairo renderer.
- */
-typedef void (* PangoCairoShapeRendererFunc) (cairo_t        *cr,
-                                             PangoAttrShape *attr,
-                                             gboolean        do_path,
-                                             gpointer        data);
-
 /*
  * PangoCairoFontMap
  */
@@ -146,15 +127,6 @@ void               pango_cairo_context_set_resolution     (PangoContext       *c
 PANGO_AVAILABLE_IN_1_10
 double             pango_cairo_context_get_resolution     (PangoContext       *context);
 
-PANGO_AVAILABLE_IN_1_18
-void                        pango_cairo_context_set_shape_renderer (PangoContext                *context,
-                                                                   PangoCairoShapeRendererFunc  func,
-                                                                   gpointer                     data,
-                                                                   GDestroyNotify               dnotify);
-PANGO_AVAILABLE_IN_1_18
-PangoCairoShapeRendererFunc pango_cairo_context_get_shape_renderer (PangoContext                *context,
-                                                                   gpointer                    *data);
-
 /* Convenience
  */
 PANGO_AVAILABLE_IN_1_22
diff --git a/pango/serializer.c b/pango/serializer.c
index a1cc4f9f..1c7c6ef4 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -392,10 +392,6 @@ add_attribute (GtkJsonPrinter *printer,
       gtk_json_printer_add_boolean (printer, "value", ((PangoAttrInt*)attr)->value != 0);
       break;
 
-    case PANGO_ATTR_SHAPE:
-      gtk_json_printer_add_string (printer, "value", "shape");
-      break;
-
     case PANGO_ATTR_SCALE:
     case PANGO_ATTR_LINE_HEIGHT:
       gtk_json_printer_add_number (printer, "value", ((PangoAttrFloat*)attr)->value);
@@ -1012,11 +1008,6 @@ attr_for_type (GtkJsonParser *parser,
       attr = pango_attr_rise_new ((int) gtk_json_parser_get_number (parser));
       break;
 
-    case PANGO_ATTR_SHAPE:
-      /* FIXME */
-      attr = pango_attr_shape_new (&(PangoRectangle) { 0, 0, 0, 0}, &(PangoRectangle) { 0, 0, 0, 0});
-      break;
-
     case PANGO_ATTR_SCALE:
       attr = pango_attr_scale_new (gtk_json_parser_get_number (parser));
       break;
diff --git a/tests/meson.build b/tests/meson.build
index 99380495..786fd8f1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -38,7 +38,6 @@ if cairo_dep.found()
     [ 'test-ellipsize', [ 'test-ellipsize.c' ] ],
     [ 'markup-parse', [ 'markup-parse.c' , 'test-common.c' ] ],
     [ 'test-itemize', [ 'test-itemize.c', 'test-common.c' ] ],
-    [ 'test-shape', [ 'test-shape.c', 'test-common.c' ] ],
     [ 'test-font', [ 'test-font.c' ] ],
     [ 'testattributes', [ 'testattributes.c', 'test-common.c' ] ],
     [ 'cxx-test', [ 'cxx-test.cpp' ] ],
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index aa217a3d..d2b13b21 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -76,7 +76,6 @@ affects_itemization (PangoAttribute *attr,
     case PANGO_ATTR_FONT_SCALE:
     /* These are part of ItemProperties, so need to break runs */
     case PANGO_ATTR_LETTER_SPACING:
-    case PANGO_ATTR_SHAPE:
     case PANGO_ATTR_RISE:
     case PANGO_ATTR_BASELINE_SHIFT:
     case PANGO_ATTR_LINE_HEIGHT:
diff --git a/tests/testattributes.c b/tests/testattributes.c
index 5d3334e8..7264f402 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -36,7 +36,6 @@ static void
 test_attributes_basic (void)
 {
   PangoFontDescription *desc;
-  PangoRectangle rect = { 0, 0, 10, 10 };
 
   test_copy (pango_attr_language_new (pango_language_from_string ("ja-JP")));
   test_copy (pango_attr_family_new ("Times"));
@@ -62,7 +61,6 @@ test_attributes_basic (void)
   test_copy (pango_attr_scale_new (2.56));
   test_copy (pango_attr_fallback_new (FALSE));
   test_copy (pango_attr_letter_spacing_new (1024));
-  test_copy (pango_attr_shape_new (&rect, &rect));
   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"));
@@ -121,10 +119,10 @@ static void
 test_binding (PangoAttribute *attr)
 {
   enum {
-    INVALID, INT, LANGUAGE, STRING, SIZE, FONT_DESC, COLOR, SHAPE, FLOAT, FONT_FEATURES,
+    INVALID, INT, LANGUAGE, STRING, SIZE, FONT_DESC, COLOR, FLOAT, FONT_FEATURES,
   } attr_base[] = {
     INVALID, LANGUAGE, STRING, INT, INT, INT, INT, SIZE, FONT_DESC, COLOR,
-    COLOR, INT, INT, INT, SHAPE, FLOAT, INT, INT, COLOR, COLOR, SIZE,
+    COLOR, INT, INT, INT, FLOAT, INT, INT, COLOR, COLOR, SIZE,
     INT, INT, FONT_FEATURES, INT, INT, INT, INT, INT, INT, COLOR, FLOAT,
     INT, INT, INT, INT, INT, INT
   };
@@ -149,9 +147,6 @@ test_binding (PangoAttribute *attr)
     case COLOR:
       g_assert_nonnull (pango_attribute_as_color (attr));
       break;
-    case SHAPE:
-      g_assert_nonnull (pango_attribute_as_shape (attr));
-      break;
     case FLOAT:
       g_assert_nonnull (pango_attribute_as_float (attr));
       break;
@@ -170,7 +165,6 @@ static void
 test_binding_helpers (void)
 {
   PangoFontDescription *desc;
-  PangoRectangle rect = { 0, 0, 10, 10 };
 
   test_binding (pango_attr_language_new (pango_language_from_string ("ja-JP")));
   test_binding (pango_attr_family_new ("Times"));
@@ -196,7 +190,6 @@ test_binding_helpers (void)
   test_binding (pango_attr_scale_new (2.56));
   test_binding (pango_attr_fallback_new (FALSE));
   test_binding (pango_attr_letter_spacing_new (1024));
-  test_binding (pango_attr_shape_new (&rect, &rect));
   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"));


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