summaryrefslogtreecommitdiff
path: root/pango/shape.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-08-20 16:16:49 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-08-20 23:16:48 -0400
commit0f9c6cabaa660b2c1c9dda75af40db17ea0d993b (patch)
tree75b748b6a0e9b701a5072405ab7d246c41a5f914 /pango/shape.c
parent230c6765314c29075ad697670d9ba5acbdcfe124 (diff)
downloadpango-0f9c6cabaa660b2c1c9dda75af40db17ea0d993b.tar.gz
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.
Diffstat (limited to 'pango/shape.c')
-rw-r--r--pango/shape.c132
1 files changed, 94 insertions, 38 deletions
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: */