[pango/pango2: 67/84] Split off pango-glyph-iter.h




commit 41322975a82b2e020b7f238fa5e23ae2303dc368
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 9 08:27:29 2022 -0400

    Split off pango-glyph-iter.h

 pango/meson.build        |   1 +
 pango/pango-glyph-item.c |   1 +
 pango/pango-glyph-item.h | 114 +++++++----------------------------------------
 pango/pango-glyph-iter.h | 108 ++++++++++++++++++++++++++++++++++++++++++++
 pango/pango.h            |   1 +
 5 files changed, 127 insertions(+), 98 deletions(-)
---
diff --git a/pango/meson.build b/pango/meson.build
index 7d5e30011..b6ff6196e 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -71,6 +71,7 @@ pango_headers = [
   'pango-generic-family.h',
   'pango-glyph.h',
   'pango-glyph-item.h',
+  'pango-glyph-iter.h',
   'pango-gravity.h',
   'pango-item.h',
   'pango-language.h',
diff --git a/pango/pango-glyph-item.c b/pango/pango-glyph-item.c
index 293e20ad0..e7455caea 100644
--- a/pango/pango-glyph-item.c
+++ b/pango/pango-glyph-item.c
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "pango-glyph-item.h"
+#include "pango-glyph-iter.h"
 #include "pango-item-private.h"
 #include "pango-impl-utils.h"
 #include "pango-attr-list-private.h"
diff --git a/pango/pango-glyph-item.h b/pango/pango-glyph-item.h
index 953d02bed..2907e0e4b 100644
--- a/pango/pango-glyph-item.h
+++ b/pango/pango-glyph-item.h
@@ -58,111 +58,29 @@ struct _PangoGlyphItem
 #define PANGO_TYPE_GLYPH_ITEM (pango_glyph_item_get_type ())
 
 PANGO_AVAILABLE_IN_ALL
-GType pango_glyph_item_get_type (void) G_GNUC_CONST;
+GType                   pango_glyph_item_get_type               (void) G_GNUC_CONST;
 
 PANGO_AVAILABLE_IN_ALL
-PangoGlyphItem *pango_glyph_item_split        (PangoGlyphItem *orig,
-                                              const char     *text,
-                                              int             split_index);
+PangoGlyphItem *        pango_glyph_item_split                  (PangoGlyphItem *orig,
+                                                                 const char     *text,
+                                                                 int             split_index);
 PANGO_AVAILABLE_IN_ALL
-PangoGlyphItem *pango_glyph_item_copy         (PangoGlyphItem *orig);
+PangoGlyphItem *        pango_glyph_item_copy                   (PangoGlyphItem *orig);
 PANGO_AVAILABLE_IN_ALL
-void            pango_glyph_item_free         (PangoGlyphItem *glyph_item);
+void                    pango_glyph_item_free                   (PangoGlyphItem *glyph_item);
 PANGO_AVAILABLE_IN_ALL
-GSList *        pango_glyph_item_apply_attrs  (PangoGlyphItem *glyph_item,
-                                              const char     *text,
-                                              PangoAttrList  *list);
+GSList *                pango_glyph_item_apply_attrs            (PangoGlyphItem *glyph_item,
+                                                                 const char     *text,
+                                                                 PangoAttrList  *list);
 PANGO_AVAILABLE_IN_ALL
-void            pango_glyph_item_letter_space (PangoGlyphItem *glyph_item,
-                                              const char     *text,
-                                              PangoLogAttr   *log_attrs,
-                                              int             letter_spacing);
+void                    pango_glyph_item_letter_space           (PangoGlyphItem *glyph_item,
+                                                                 const char     *text,
+                                                                 PangoLogAttr   *log_attrs,
+                                                                 int             letter_spacing);
 PANGO_AVAILABLE_IN_ALL
-void     pango_glyph_item_get_logical_widths (PangoGlyphItem *glyph_item,
-                                              const char     *text,
-                                              int            *logical_widths);
+void                    pango_glyph_item_get_logical_widths     (PangoGlyphItem *glyph_item,
+                                                                 const char     *text,
+                                                                 int            *logical_widths);
 
 
-/**
- * PangoGlyphItemIter:
- *
- * A `PangoGlyphItemIter` is an iterator over the clusters in a
- * `PangoGlyphItem`.
- *
- * The *forward direction* of the iterator is the logical direction of text.
- * That is, with increasing @start_index and @start_char values. If @glyph_item
- * is right-to-left (that is, if `glyph_item->item->analysis.level` is odd),
- * then @start_glyph decreases as the iterator moves forward.  Moreover,
- * in right-to-left cases, @start_glyph is greater than @end_glyph.
- *
- * An iterator should be initialized using either
- * pango_glyph_item_iter_init_start() or
- * pango_glyph_item_iter_init_end(), for forward and backward iteration
- * respectively, and walked over using any desired mixture of
- * pango_glyph_item_iter_next_cluster() and
- * pango_glyph_item_iter_prev_cluster().
- *
- * A common idiom for doing a forward iteration over the clusters is:
- *
- * ```
- * PangoGlyphItemIter cluster_iter;
- * gboolean have_cluster;
- *
- * for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
- *                                                       glyph_item, text);
- *      have_cluster;
- *      have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
- * {
- *   ...
- * }
- * ```
- *
- * Note that @text is the start of the text for layout, which is then
- * indexed by `glyph_item->item->offset` to get to the text of @glyph_item.
- * The @start_index and @end_index values can directly index into @text. The
- * @start_glyph, @end_glyph, @start_char, and @end_char values however are
- * zero-based for the @glyph_item.  For each cluster, the item pointed at by
- * the start variables is included in the cluster while the one pointed at by
- * end variables is not.
- *
- * None of the members of a `PangoGlyphItemIter` should be modified manually.
- */
-typedef struct _PangoGlyphItemIter PangoGlyphItemIter;
-
-struct _PangoGlyphItemIter
-{
-  PangoGlyphItem *glyph_item;
-  const gchar *text;
-
-  int start_glyph;
-  int start_index;
-  int start_char;
-
-  int end_glyph;
-  int end_index;
-  int end_char;
-};
-
-#define PANGO_TYPE_GLYPH_ITEM_ITER (pango_glyph_item_iter_get_type ())
-
-PANGO_AVAILABLE_IN_ALL
-GType               pango_glyph_item_iter_get_type (void) G_GNUC_CONST;
-PANGO_AVAILABLE_IN_ALL
-PangoGlyphItemIter *pango_glyph_item_iter_copy (PangoGlyphItemIter *orig);
-PANGO_AVAILABLE_IN_ALL
-void                pango_glyph_item_iter_free (PangoGlyphItemIter *iter);
-
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_glyph_item_iter_init_start   (PangoGlyphItemIter *iter,
-                                            PangoGlyphItem     *glyph_item,
-                                            const char         *text);
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_glyph_item_iter_init_end     (PangoGlyphItemIter *iter,
-                                            PangoGlyphItem     *glyph_item,
-                                            const char         *text);
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter);
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter);
-
 G_END_DECLS
diff --git a/pango/pango-glyph-iter.h b/pango/pango-glyph-iter.h
new file mode 100644
index 000000000..987c15aa2
--- /dev/null
+++ b/pango/pango-glyph-iter.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2002 Red Hat Software
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <pango/pango-glyph-item.h>
+
+G_BEGIN_DECLS
+
+/**
+ * PangoGlyphItemIter:
+ *
+ * A `PangoGlyphItemIter` is an iterator over the clusters in a
+ * `PangoGlyphItem`.
+ *
+ * The *forward direction* of the iterator is the logical direction of text.
+ * That is, with increasing @start_index and @start_char values. If @glyph_item
+ * is right-to-left (that is, if `glyph_item->item->analysis.level` is odd),
+ * then @start_glyph decreases as the iterator moves forward.  Moreover,
+ * in right-to-left cases, @start_glyph is greater than @end_glyph.
+ *
+ * An iterator should be initialized using either
+ * pango_glyph_item_iter_init_start() or
+ * pango_glyph_item_iter_init_end(), for forward and backward iteration
+ * respectively, and walked over using any desired mixture of
+ * pango_glyph_item_iter_next_cluster() and
+ * pango_glyph_item_iter_prev_cluster().
+ *
+ * A common idiom for doing a forward iteration over the clusters is:
+ *
+ * ```
+ * PangoGlyphItemIter cluster_iter;
+ * gboolean have_cluster;
+ *
+ * for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
+ *                                                       glyph_item, text);
+ *      have_cluster;
+ *      have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
+ * {
+ *   ...
+ * }
+ * ```
+ *
+ * Note that @text is the start of the text for layout, which is then
+ * indexed by `glyph_item->item->offset` to get to the text of @glyph_item.
+ * The @start_index and @end_index values can directly index into @text. The
+ * @start_glyph, @end_glyph, @start_char, and @end_char values however are
+ * zero-based for the @glyph_item.  For each cluster, the item pointed at by
+ * the start variables is included in the cluster while the one pointed at by
+ * end variables is not.
+ *
+ * None of the members of a `PangoGlyphItemIter` should be modified manually.
+ */
+typedef struct _PangoGlyphItemIter PangoGlyphItemIter;
+
+struct _PangoGlyphItemIter
+{
+  PangoGlyphItem *glyph_item;
+  const gchar *text;
+
+  int start_glyph;
+  int start_index;
+  int start_char;
+
+  int end_glyph;
+  int end_index;
+  int end_char;
+};
+
+#define PANGO_TYPE_GLYPH_ITEM_ITER (pango_glyph_item_iter_get_type ())
+
+PANGO_AVAILABLE_IN_ALL
+GType                   pango_glyph_item_iter_get_type     (void) G_GNUC_CONST;
+PANGO_AVAILABLE_IN_ALL
+PangoGlyphItemIter *    pango_glyph_item_iter_copy         (PangoGlyphItemIter *orig);
+PANGO_AVAILABLE_IN_ALL
+void                    pango_glyph_item_iter_free         (PangoGlyphItemIter *iter);
+
+PANGO_AVAILABLE_IN_ALL
+gboolean                pango_glyph_item_iter_init_start   (PangoGlyphItemIter *iter,
+                                                            PangoGlyphItem     *glyph_item,
+                                                            const char         *text);
+PANGO_AVAILABLE_IN_ALL
+gboolean                pango_glyph_item_iter_init_end     (PangoGlyphItemIter *iter,
+                                                            PangoGlyphItem     *glyph_item,
+                                                             const char         *text);
+PANGO_AVAILABLE_IN_ALL
+gboolean                pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter);
+PANGO_AVAILABLE_IN_ALL
+gboolean                pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter);
+
+G_END_DECLS
diff --git a/pango/pango.h b/pango/pango.h
index f90652580..8b0c36c15 100644
--- a/pango/pango.h
+++ b/pango/pango.h
@@ -39,6 +39,7 @@
 #include <pango/pango-generic-family.h>
 #include <pango/pango-glyph.h>
 #include <pango/pango-glyph-item.h>
+#include <pango/pango-glyph-iter.h>
 #include <pango/pango-gravity.h>
 #include <pango/pango-hbface.h>
 #include <pango/pango-hbfont.h>


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