diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-02-08 15:21:34 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-02-17 14:01:45 -0600 |
commit | d7e236b34211c19ae2a7dd6d20142869161a0367 (patch) | |
tree | f0c0c06b45c0a3f11de54f35faf727845499c5d3 | |
parent | 19da30b980011caaf1f8e658ddfbfc137216ad11 (diff) | |
download | pango-d7e236b34211c19ae2a7dd6d20142869161a0367.tar.gz |
Clean up break api a bit
Remove an unused argument, and pass attributs
to pango_get_log_attrs().
-rw-r--r-- | pango/break.c | 23 | ||||
-rw-r--r-- | pango/pango-break.h | 2 | ||||
-rw-r--r-- | pango/pango-layout.c | 2 | ||||
-rw-r--r-- | tests/testboundaries.c | 7 | ||||
-rw-r--r-- | tests/testboundaries_ucd.c | 2 |
5 files changed, 16 insertions, 20 deletions
diff --git a/pango/break.c b/pango/break.c index 3b4b1b0d..db36847c 100644 --- a/pango/break.c +++ b/pango/break.c @@ -142,7 +142,6 @@ typedef enum static void default_break (const char *text, int length, - PangoAnalysis *analysis G_GNUC_UNUSED, PangoLogAttr *attrs, int attrs_len G_GNUC_UNUSED) { @@ -2162,30 +2161,27 @@ tailor_break (const char *text, * pango_default_break: * @text: text to break. Must be valid UTF-8 * @length: length of text in bytes (may be -1 if @text is nul-terminated) - * @analysis: (nullable): a `PangoAnalysis` structure for the @text * @attrs: logical attributes to fill in * @attrs_len: size of the array passed as @attrs * * This is the default break algorithm. * * It applies rules from the [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/) - * without language-specific tailoring, therefore the @analyis argument is unused - * and can be %NULL. + * without language-specific tailoring. * * See [func@Pango.tailor_break] for language-specific breaks. * * See [func@Pango.attr_break] for attribute-based customization. */ void -pango_default_break (const char *text, - int length, - PangoAnalysis *analysis G_GNUC_UNUSED, - PangoLogAttr *attrs, - int attrs_len G_GNUC_UNUSED) +pango_default_break (const char *text, + int length, + PangoLogAttr *attrs, + int attrs_len G_GNUC_UNUSED) { PangoLogAttr before = *attrs; - default_break (text, length, analysis, attrs, attrs_len); + default_break (text, length, attrs, attrs_len); attrs->is_line_break |= before.is_line_break; attrs->is_mandatory_break |= before.is_mandatory_break; @@ -2290,6 +2286,7 @@ pango_attr_break (const char *text, * pango_get_log_attrs: * @text: text to process. Must be valid UTF-8 * @length: length in bytes of @text + * @attr_list: (nullable): `PangoAttrList` to apply * @level: embedding level, or -1 if unknown * @language: language tag * @attrs: (array length=attrs_len): array with one `PangoLogAttr` @@ -2309,6 +2306,7 @@ pango_attr_break (const char *text, void pango_get_log_attrs (const char *text, int length, + PangoAttrList *attr_list, int level, PangoLanguage *language, PangoLogAttr *attrs, @@ -2324,7 +2322,7 @@ pango_get_log_attrs (const char *text, analysis.level = level; analysis.language = language; - pango_default_break (text, length, &analysis, attrs, attrs_len); + pango_default_break (text, length, attrs, attrs_len); chars_broken = 0; @@ -2352,6 +2350,9 @@ pango_get_log_attrs (const char *text, while (pango_script_iter_next (&iter)); _pango_script_iter_fini (&iter); + if (attr_list) + pango_attr_break (text, length, attr_list, 0, attrs, attrs_len); + if (chars_broken + 1 > attrs_len) g_warning ("pango_get_log_attrs: attrs_len should have been at least %d, but was %d. Expect corrupted memory.", chars_broken + 1, diff --git a/pango/pango-break.h b/pango/pango-break.h index 021af0d4..55274211 100644 --- a/pango/pango-break.h +++ b/pango/pango-break.h @@ -104,6 +104,7 @@ struct _PangoLogAttr PANGO_AVAILABLE_IN_ALL void pango_get_log_attrs (const char *text, int length, + PangoAttrList *attr_list, int level, PangoLanguage *language, PangoLogAttr *attrs, @@ -112,7 +113,6 @@ void pango_get_log_attrs (const char *text, PANGO_AVAILABLE_IN_ALL void pango_default_break (const char *text, int length, - PangoAnalysis *analysis, PangoLogAttr *attrs, int attrs_len); diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 5ca4122b..84fe13d6 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -4597,7 +4597,7 @@ get_items_log_attrs (const char *text, int offset = 0; GList *l; - pango_default_break (text + start, length, NULL, log_attrs, log_attrs_len); + pango_default_break (text + start, length, log_attrs, log_attrs_len); for (l = items; l; l = l->next) { diff --git a/tests/testboundaries.c b/tests/testboundaries.c index dbc3b5b7..c492b577 100644 --- a/tests/testboundaries.c +++ b/tests/testboundaries.c @@ -282,12 +282,7 @@ check_invariants (const char *text) len = g_utf8_strlen (text, -1); attrs = g_new0 (PangoLogAttr, len + 1); - pango_get_log_attrs (text, - -1, - 0, - pango_language_from_string ("C"), - attrs, - len + 1); + pango_get_log_attrs (text, -1, NULL, 0, pango_language_from_string ("C"), attrs, len + 1); check_line_invariants (text, attrs); check_sentence_invariants (text, attrs); diff --git a/tests/testboundaries_ucd.c b/tests/testboundaries_ucd.c index bcc7ed45..f69769cc 100644 --- a/tests/testboundaries_ucd.c +++ b/tests/testboundaries_ucd.c @@ -274,7 +274,7 @@ do_test (const gchar *filename, if (num_attrs > 0) { PangoLogAttr *attrs = g_new0 (PangoLogAttr, num_attrs); - pango_get_log_attrs (string, -1, 0, pango_language_from_string ("C"), attrs, num_attrs); + pango_get_log_attrs (string, -1, NULL, 0, pango_language_from_string ("C"), attrs, num_attrs); if (! attrs_equal (attrs, expected_attrs, num_attrs, bits)) { |