diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-07 11:11:45 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-08 08:38:06 -0500 |
commit | b9b92e79da0e55acf0c13968ca699d4dd78fc614 (patch) | |
tree | 9f4f082957cb907927c22d241a51b2bf467dfbd3 /pango | |
parent | cb6a93fb8ac99b155cf73ed0decd1c8a1230caa3 (diff) | |
download | pango-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')
-rw-r--r-- | pango/itemize.c | 64 | ||||
-rw-r--r-- | pango/pango-item-private.h | 6 | ||||
-rw-r--r-- | pango/pango-layout.c | 20 |
3 files changed, 59 insertions, 31 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); } /* }}} */ diff --git a/pango/pango-item-private.h b/pango/pango-item-private.h index e80a3c02..ef3e8ed0 100644 --- a/pango/pango-item-private.h +++ b/pango/pango-item-private.h @@ -22,6 +22,7 @@ #define __PANGO_ITEM_PRIVATE_H__ #include <pango/pango-item.h> +#include <pango/pango-break.h> G_BEGIN_DECLS @@ -82,6 +83,11 @@ GList * pango_itemize_with_font (PangoContext PangoAttrIterator *cached_iter, const PangoFontDescription *desc); +GList * pango_itemize_post_process_items (PangoContext *context, + const char *text, + PangoLogAttr *log_attrs, + GList *items); + G_END_DECLS diff --git a/pango/pango-layout.c b/pango/pango-layout.c index ba81adf6..9e8ce248 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -4534,13 +4534,14 @@ pango_layout_check_lines (PangoLayout *layout) g_assert (delim_len >= 0); state.attrs = itemize_attrs; - state.items = pango_itemize_with_base_dir (layout->context, - base_dir, - layout->text, - start - layout->text, - end - start, - itemize_attrs, - itemize_attrs ? &iter : NULL); + state.items = pango_itemize_with_font (layout->context, + base_dir, + layout->text, + start - layout->text, + end - start, + itemize_attrs, + itemize_attrs ? &iter : NULL, + NULL); apply_attributes_to_items (state.items, shape_attrs); @@ -4553,6 +4554,11 @@ pango_layout_check_lines (PangoLayout *layout) layout->log_attrs + start_offset, layout->n_chars + 1 - start_offset); + state.items = pango_itemize_post_process_items (layout->context, + layout->text, + layout->log_attrs + start_offset, + state.items); + state.base_dir = base_dir; state.line_of_par = 1; state.start_offset = start_offset; |