summaryrefslogtreecommitdiff
path: root/pango/itemize.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-07 11:11:45 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-11-08 08:38:06 -0500
commitb9b92e79da0e55acf0c13968ca699d4dd78fc614 (patch)
tree9f4f082957cb907927c22d241a51b2bf467dfbd3 /pango/itemize.c
parentcb6a93fb8ac99b155cf73ed0decd1c8a1230caa3 (diff)
downloadpango-b9b92e79da0e55acf0c13968ca699d4dd78fc614.tar.gz
Reshuffle itemize API
Split the post-processing off into a separate function that can take log attrs in addition. This will allow us to handle word starts when dealing with text transforms for emulated Small Caps. So far, this is all private API that is used from PangoLayout. Please file an issue if you want to access Small Caps emulation without PangoLayout.
Diffstat (limited to 'pango/itemize.c')
-rw-r--r--pango/itemize.c64
1 files changed, 40 insertions, 24 deletions
diff --git a/pango/itemize.c b/pango/itemize.c
index e39e6fe2..b5f544a7 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -1435,26 +1435,30 @@ handle_variants (const char *text,
/* }}} */
static GList *
-post_process_items (PangoContext *context,
- const char *text,
- GList *items)
+reorder_items (PangoContext *context,
+ GList *items)
{
+ int char_offset = 0;
+
items = g_list_reverse (items);
- /* Compute the char offset for each item */
- {
- int char_offset = 0;
- for (GList *l = items; l; l = l->next)
- {
- PangoItemPrivate *item = l->data;
- item->char_offset = char_offset;
- char_offset += item->num_chars;
- }
- }
+ /* Also cmpute the char offset for each item here */
+ for (GList *l = items; l; l = l->next)
+ {
+ PangoItemPrivate *item = l->data;
+ item->char_offset = char_offset;
+ char_offset += item->num_chars;
+ }
- handle_variants (text, items);
+ return items;
+}
- /* apply font-scale */
+static GList *
+post_process_items (PangoContext *context,
+ const char *text,
+ GList *items)
+{
+ handle_variants (text, items);
apply_font_scale (context, items);
return items;
@@ -1488,7 +1492,16 @@ pango_itemize_with_font (PangoContext *context,
itemize_state_finish (&state);
- return post_process_items (context, text, state.result);
+ return reorder_items (context, state.result);
+}
+
+GList *
+pango_itemize_post_process_items (PangoContext *context,
+ const char *text,
+ PangoLogAttr *log_attrs,
+ GList *items)
+{
+ return post_process_items (context, text, items);
}
/* }}} */
@@ -1527,15 +1540,19 @@ pango_itemize_with_base_dir (PangoContext *context,
PangoAttrList *attrs,
PangoAttrIterator *cached_iter)
{
+ GList *items;
+
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (start_index >= 0, NULL);
g_return_val_if_fail (length >= 0, NULL);
g_return_val_if_fail (length == 0 || text != NULL, NULL);
- return pango_itemize_with_font (context, base_dir,
- text, start_index, length,
- attrs, cached_iter,
- NULL);
+ items = pango_itemize_with_font (context, base_dir,
+ text, start_index, length,
+ attrs, cached_iter,
+ NULL);
+
+ return pango_itemize_post_process_items (context, text, NULL, items);
}
/**
@@ -1579,10 +1596,9 @@ pango_itemize (PangoContext *context,
g_return_val_if_fail (length >= 0, NULL);
g_return_val_if_fail (length == 0 || text != NULL, NULL);
- return pango_itemize_with_font (context, context->base_dir,
- text, start_index, length,
- attrs, cached_iter,
- NULL);
+ return pango_itemize_with_base_dir (context, context->base_dir,
+ text, start_index, length,
+ attrs, cached_iter);
}
/* }}} */