summaryrefslogtreecommitdiff
path: root/pango/itemize.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-08-28 11:12:35 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-08-28 11:15:05 -0400
commit1fcd5ae9a9dfd3a7c5ccacd11ffd54a3ad93e643 (patch)
tree9521186e09c87931d780f4e6988f3e84035aa987 /pango/itemize.c
parent94e5f18e80aeb95b14217ed7f7efa790eb48c3c9 (diff)
downloadpango-1fcd5ae9a9dfd3a7c5ccacd11ffd54a3ad93e643.tar.gz
Cosmetic
Improve the itemization code to have all variants take the same code paths, so we can do fixups in one place.
Diffstat (limited to 'pango/itemize.c')
-rw-r--r--pango/itemize.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/pango/itemize.c b/pango/itemize.c
index 27a9865d..bd699bce 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -700,7 +700,7 @@ itemize_state_add_character (ItemizeState *state,
break;
}
- state->item->analysis.flags = state->centered_baseline ? PANGO_ANALYSIS_FLAG_CENTERED_BASELINE : 0;
+ state->item->analysis.flags |= state->centered_baseline ? PANGO_ANALYSIS_FLAG_CENTERED_BASELINE : 0;
state->item->analysis.script = state->script;
state->item->analysis.language = state->derived_lang;
@@ -1021,21 +1021,24 @@ itemize_state_finish (ItemizeState *state)
/* }}} */
/* {{{ Public API */
-/* Like pango_itemize, but takes a font description */
+/* Like pango_itemize_with_base_dir, but takes a font description */
GList *
pango_itemize_with_font (PangoContext *context,
+ PangoDirection base_dir,
const char *text,
int start_index,
int length,
+ PangoAttrList *attrs,
+ PangoAttrIterator *cached_iter,
const PangoFontDescription *desc)
{
ItemizeState state;
- if (length == 0)
+ if (length == 0 || g_utf8_get_char (text + start_index) == '\0')
return NULL;
- itemize_state_init (&state, context, text, context->base_dir, start_index, length,
- NULL, NULL, desc);
+ itemize_state_init (&state, context, text, base_dir, start_index, length,
+ attrs, cached_iter, desc);
do
itemize_state_process_run (&state);
@@ -1079,26 +1082,15 @@ pango_itemize_with_base_dir (PangoContext *context,
PangoAttrList *attrs,
PangoAttrIterator *cached_iter)
{
- ItemizeState state;
-
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);
- if (length == 0 || g_utf8_get_char (text + start_index) == '\0')
- return NULL;
-
- itemize_state_init (&state, context, text, base_dir, start_index, length,
- attrs, cached_iter, NULL);
-
- do
- itemize_state_process_run (&state);
- while (itemize_state_next (&state));
-
- itemize_state_finish (&state);
-
- return g_list_reverse (state.result);
+ return pango_itemize_with_font (context, base_dir,
+ text, start_index, length,
+ attrs, cached_iter,
+ NULL);
}
/**
@@ -1142,8 +1134,10 @@ 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_base_dir (context, context->base_dir,
- text, start_index, length, attrs, cached_iter);
+ return pango_itemize_with_font (context, context->base_dir,
+ text, start_index, length,
+ attrs, cached_iter,
+ NULL);
}
/* }}} */