[pango/text-transform-3: 4/9] Add pango_shape_item




commit 0f9c6cabaa660b2c1c9dda75af40db17ea0d993b
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 20 16:16:49 2021 -0400

    Add pango_shape_item
    
    Add a pango_shape API variant that takes log attrs,
    so we can implement text transforms that depend on
    word boundaries, in the future.

 pango/pango-glyph.h |   9 ++++
 pango/shape.c       | 132 +++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 103 insertions(+), 38 deletions(-)
---
diff --git a/pango/pango-glyph.h b/pango/pango-glyph.h
index ae1f5fd7..4dc77fd1 100644
--- a/pango/pango-glyph.h
+++ b/pango/pango-glyph.h
@@ -228,6 +228,15 @@ void                    pango_shape_with_flags                  (const char
                                                                  PangoShapeFlags      flags);
 
 
+PANGO_AVAILABLE_IN_1_50
+void                    pango_shape_item                        (PangoItem           *item,
+                                                                 const char          *paragraph_text,
+                                                                 int                  paragraph_length,
+                                                                 PangoLogAttr        *log_attrs,
+                                                                 PangoGlyphString    *glyphs,
+                                                                 PangoShapeFlags      flags);
+
+
 G_END_DECLS
 
 #endif /* __PANGO_GLYPH_H__ */
diff --git a/pango/shape.c b/pango/shape.c
index 8743fad3..23325bbf 100644
--- a/pango/shape.c
+++ b/pango/shape.c
@@ -324,6 +324,7 @@ pango_hb_shape (const char          *item_text,
                 const char          *paragraph_text,
                 int                  paragraph_length,
                 const PangoAnalysis *analysis,
+                PangoLogAttr        *log_attrs,
                 PangoGlyphString    *glyphs,
                 PangoShapeFlags      flags)
 {
@@ -562,44 +563,15 @@ pango_shape_full (const char          *item_text,
                           PANGO_SHAPE_NONE);
 }
 
-/**
- * pango_shape_with_flags:
- * @item_text: valid UTF-8 text to shape
- * @item_length: the length (in bytes) of @item_text.
- *     -1 means nul-terminated text.
- * @paragraph_text: (nullable): text of the paragraph (see details).
- *     May be %NULL.
- * @paragraph_length: the length (in bytes) of @paragraph_text.
- *     -1 means nul-terminated text.
- * @analysis:  `PangoAnalysis` structure from [func@itemize]
- * @glyphs: glyph string in which to store results
- * @flags: flags influencing the shaping process
- *
- * Convert the characters in @text into glyphs.
- *
- * Given a segment of text and the corresponding `PangoAnalysis` structure
- * returned from [func@itemize], convert the characters into glyphs. You may
- * also pass in only a substring of the item from [func@itemize].
- *
- * This is similar to [func@shape_full], except it also takes flags that can
- * influence the shaping process.
- *
- * Note that the extra attributes in the @analyis that is returned from
- * [func@itemize] have indices that are relative to the entire paragraph,
- * so you do not pass the full paragraph text as @paragraph_text, you need
- * to subtract the item offset from their indices before calling
- * [func@shape_with_flags].
- *
- * Since: 1.44
- */
-void
-pango_shape_with_flags (const char          *item_text,
-                        int                  item_length,
-                        const char          *paragraph_text,
-                        int                  paragraph_length,
-                        const PangoAnalysis *analysis,
-                        PangoGlyphString    *glyphs,
-                        PangoShapeFlags      flags)
+static void
+pango_shape_with_all (const char          *item_text,
+                      int                  item_length,
+                      const char          *paragraph_text,
+                      int                  paragraph_length,
+                      const PangoAnalysis *analysis,
+                      PangoLogAttr        *log_attrs,
+                      PangoGlyphString    *glyphs,
+                      PangoShapeFlags      flags)
 {
   int i;
   int last_cluster;
@@ -625,6 +597,7 @@ pango_shape_with_flags (const char          *item_text,
       pango_hb_shape (item_text, item_length,
                       paragraph_text, paragraph_length,
                       analysis,
+                      log_attrs,
                       glyphs,
                       flags);
 
@@ -767,6 +740,89 @@ pango_shape_with_flags (const char          *item_text,
     }
 }
 
+/**
+ * pango_shape_with_flags:
+ * @item_text: valid UTF-8 text to shape
+ * @item_length: the length (in bytes) of @item_text.
+ *     -1 means nul-terminated text.
+ * @paragraph_text: (nullable): text of the paragraph (see details).
+ *     May be %NULL.
+ * @paragraph_length: the length (in bytes) of @paragraph_text.
+ *     -1 means nul-terminated text.
+ * @analysis:  `PangoAnalysis` structure from [func@itemize]
+ * @glyphs: glyph string in which to store results
+ * @flags: flags influencing the shaping process
+ *
+ * Convert the characters in @text into glyphs.
+ *
+ * Given a segment of text and the corresponding `PangoAnalysis` structure
+ * returned from [func@itemize], convert the characters into glyphs. You may
+ * also pass in only a substring of the item from [func@itemize].
+ *
+ * This is similar to [func@shape_full], except it also takes flags that can
+ * influence the shaping process.
+ *
+ * Note that the extra attributes in the @analyis that is returned from
+ * [func@itemize] have indices that are relative to the entire paragraph,
+ * so you do not pass the full paragraph text as @paragraph_text, you need
+ * to subtract the item offset from their indices before calling
+ * [func@shape_with_flags].
+ *
+ * Since: 1.44
+ */
+void
+pango_shape_with_flags (const char          *item_text,
+                        int                  item_length,
+                        const char          *paragraph_text,
+                        int                  paragraph_length,
+                        const PangoAnalysis *analysis,
+                        PangoGlyphString    *glyphs,
+                        PangoShapeFlags      flags)
+{
+  pango_shape_with_all (item_text, item_length,
+                        paragraph_text, paragraph_length,
+                        analysis, NULL,
+                        glyphs, flags);
+}
+
+/**
+ * pango_shape_item:
+ * @item: `PangoItem` to shape
+ * @paragraph_text: (nullable): text of the paragraph (see details).
+ *     May be %NULL.
+ * @paragraph_length: the length (in bytes) of @paragraph_text.
+ *     -1 means nul-terminated text.
+ * @log_attrs: (nullable): array of `PangoLogAttr` for @item
+ * @glyphs: glyph string in which to store results
+ * @flags: flags influencing the shaping process
+ *
+ * Convert the characters in @item into glyphs.
+ *
+ * This is similar to [func@shape_with_flags], except it takes a `PangoItem`
+ * instead of separate @item_text and @analysis arguments. It also takes
+ * @log_attrs, which may be used in implementing text transforms.
+ *
+ * Note that the extra attributes in the @analyis that is returned from
+ * [func@itemize] have indices that are relative to the entire paragraph,
+ * so you do not pass the full paragraph text as @paragraph_text, you need
+ * to subtract the item offset from their indices before calling
+ * [func@shape_with_flags].
+ *
+ * Since: 1.50
+ */
+void
+pango_shape_item (PangoItem        *item,
+                  const char       *paragraph_text,
+                  int               paragraph_length,
+                  PangoLogAttr     *log_attrs,
+                  PangoGlyphString *glyphs,
+                  PangoShapeFlags   flags)
+{
+  pango_shape_with_all (paragraph_text + item->offset, item->length,
+                        paragraph_text, paragraph_length,
+                        &item->analysis, log_attrs,
+                        glyphs, flags);
+}
 /* }}} */
 
 /* vim:set foldmethod=marker expandtab: */


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