diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-01-10 13:46:46 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-02-17 14:01:09 -0600 |
commit | 6ffb825d3724630926b8f2f1e1aa61f07da38795 (patch) | |
tree | ca2315a0c0e346f9cd31a669d7aebd230a719b82 | |
parent | 0c5df1c8e6eb06af417e37df6e0c225038365031 (diff) | |
download | pango-6ffb825d3724630926b8f2f1e1aa61f07da38795.tar.gz |
Drop deprecated bidi api
-rw-r--r-- | pango/meson.build | 1 | ||||
-rw-r--r-- | pango/pango-bidi-type.c | 121 | ||||
-rw-r--r-- | pango/pango-bidi-type.h | 117 | ||||
-rw-r--r-- | pango/pango-layout.c | 1 | ||||
-rw-r--r-- | pango/pango-script.h | 3 | ||||
-rw-r--r-- | pango/pango-types.h | 2 | ||||
-rw-r--r-- | pango/pango-utils-internal.h | 3 | ||||
-rw-r--r-- | pango/pango-utils.c | 43 | ||||
-rw-r--r-- | pango/pango.h | 1 | ||||
-rw-r--r-- | tests/test-bidi.c | 88 |
10 files changed, 32 insertions, 348 deletions
diff --git a/pango/meson.build b/pango/meson.build index aca5b1e8..d8ecb64e 100644 --- a/pango/meson.build +++ b/pango/meson.build @@ -34,7 +34,6 @@ pango_sources = [ pango_headers = [ 'pango.h', 'pango-attributes.h', - 'pango-bidi-type.h', 'pango-break.h', 'pango-color.h', 'pango-context.h', diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c index f854a1b8..3b67ed55 100644 --- a/pango/pango-bidi-type.c +++ b/pango/pango-bidi-type.c @@ -25,65 +25,8 @@ #include <fribidi.h> -#undef PANGO_DISABLE_DEPRECATED - -#include "pango-bidi-type.h" #include "pango-utils.h" - -/** - * pango_bidi_type_for_unichar: - * @ch: a Unicode character - * - * Determines the bidirectional type of a character. - * - * The bidirectional type is specified in the Unicode Character Database. - * - * A simplified version of this function is available as [func@unichar_direction]. - * - * Return value: the bidirectional character type, as used in the - * Unicode bidirectional algorithm. - * - * Since: 1.22 - */ -PangoBidiType -pango_bidi_type_for_unichar (gunichar ch) -{ - FriBidiCharType fribidi_ch_type; - - G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar)); - - fribidi_ch_type = fribidi_get_bidi_type (ch); - - switch (fribidi_ch_type) - { - case FRIBIDI_TYPE_LTR: return PANGO_BIDI_TYPE_L; - case FRIBIDI_TYPE_LRE: return PANGO_BIDI_TYPE_LRE; - case FRIBIDI_TYPE_LRO: return PANGO_BIDI_TYPE_LRO; - case FRIBIDI_TYPE_RTL: return PANGO_BIDI_TYPE_R; - case FRIBIDI_TYPE_AL: return PANGO_BIDI_TYPE_AL; - case FRIBIDI_TYPE_RLE: return PANGO_BIDI_TYPE_RLE; - case FRIBIDI_TYPE_RLO: return PANGO_BIDI_TYPE_RLO; - case FRIBIDI_TYPE_PDF: return PANGO_BIDI_TYPE_PDF; - case FRIBIDI_TYPE_EN: return PANGO_BIDI_TYPE_EN; - case FRIBIDI_TYPE_ES: return PANGO_BIDI_TYPE_ES; - case FRIBIDI_TYPE_ET: return PANGO_BIDI_TYPE_ET; - case FRIBIDI_TYPE_AN: return PANGO_BIDI_TYPE_AN; - case FRIBIDI_TYPE_CS: return PANGO_BIDI_TYPE_CS; - case FRIBIDI_TYPE_NSM: return PANGO_BIDI_TYPE_NSM; - case FRIBIDI_TYPE_BN: return PANGO_BIDI_TYPE_BN; - case FRIBIDI_TYPE_BS: return PANGO_BIDI_TYPE_B; - case FRIBIDI_TYPE_SS: return PANGO_BIDI_TYPE_S; - case FRIBIDI_TYPE_WS: return PANGO_BIDI_TYPE_WS; - case FRIBIDI_TYPE_ON: return PANGO_BIDI_TYPE_ON; - case FRIBIDI_TYPE_LRI: return PANGO_BIDI_TYPE_LRI; - case FRIBIDI_TYPE_RLI: return PANGO_BIDI_TYPE_RLI; - case FRIBIDI_TYPE_FSI: return PANGO_BIDI_TYPE_FSI; - case FRIBIDI_TYPE_PDI: return PANGO_BIDI_TYPE_PDI; - case _FRIBIDI_TYPE_SENTINEL: - default: - return PANGO_BIDI_TYPE_ON; - } -} +#include "pango-utils-internal.h" /* Some bidi-related functions */ @@ -240,23 +183,7 @@ resolved: return embedding_levels_list; } -/** - * pango_unichar_direction: - * @ch: a Unicode character - * - * Determines the inherent direction of a character. - * - * The inherent direction is either `PANGO_DIRECTION_LTR`, `PANGO_DIRECTION_RTL`, - * or `PANGO_DIRECTION_NEUTRAL`. - * - * This function is useful to categorize characters into left-to-right - * letters, right-to-left letters, and everything else. If full Unicode - * bidirectional type of a character is needed, [func@Pango.BidiType.for_unichar] - * can be used instead. - * - * Return value: the direction of the character. - */ -PangoDirection +static PangoDirection pango_unichar_direction (gunichar ch) { FriBidiCharType fribidi_ch_type; @@ -273,26 +200,28 @@ pango_unichar_direction (gunichar ch) return PANGO_DIRECTION_LTR; } - -/** - * pango_get_mirror_char: - * @ch: a Unicode character - * @mirrored_ch: location to store the mirrored character - * - * Returns the mirrored character of a Unicode character. - * - * Mirror characters are determined by the Unicode mirrored property. - * - * Return value: %TRUE if @ch has a mirrored character and @mirrored_ch is - * filled in, %FALSE otherwise - * - * Deprecated: 1.30: Use [func@GLib.unichar_get_mirror_char] instead; - * the docs for that function provide full details. - */ -gboolean -pango_get_mirror_char (gunichar ch, - gunichar *mirrored_ch) +PangoDirection +pango_find_base_dir (const gchar *text, + gint length) { - return g_unichar_get_mirror_char (ch, mirrored_ch); -} + PangoDirection dir = PANGO_DIRECTION_NEUTRAL; + const gchar *p; + + g_return_val_if_fail (text != NULL || length == 0, PANGO_DIRECTION_NEUTRAL); + + p = text; + while ((length < 0 || p < text + length) && *p) + { + gunichar wc = g_utf8_get_char (p); + + + dir = pango_unichar_direction (wc); + if (dir != PANGO_DIRECTION_NEUTRAL) + break; + + p = g_utf8_next_char (p); + } + + return dir; +} diff --git a/pango/pango-bidi-type.h b/pango/pango-bidi-type.h deleted file mode 100644 index dbca4683..00000000 --- a/pango/pango-bidi-type.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Pango - * pango-bidi-type.h: Bidirectional Character Types - * - * Copyright (C) 2008 Jürg Billeter <j@bitron.ch> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __PANGO_BIDI_TYPE_H__ -#define __PANGO_BIDI_TYPE_H__ - -#include <glib.h> - -#include <pango/pango-version-macros.h> -#include <pango/pango-direction.h> - -G_BEGIN_DECLS - -#ifndef PANGO_DISABLE_DEPRECATED -/** - * PangoBidiType: - * @PANGO_BIDI_TYPE_L: Left-to-Right - * @PANGO_BIDI_TYPE_LRE: Left-to-Right Embedding - * @PANGO_BIDI_TYPE_LRO: Left-to-Right Override - * @PANGO_BIDI_TYPE_R: Right-to-Left - * @PANGO_BIDI_TYPE_AL: Right-to-Left Arabic - * @PANGO_BIDI_TYPE_RLE: Right-to-Left Embedding - * @PANGO_BIDI_TYPE_RLO: Right-to-Left Override - * @PANGO_BIDI_TYPE_PDF: Pop Directional Format - * @PANGO_BIDI_TYPE_EN: European Number - * @PANGO_BIDI_TYPE_ES: European Number Separator - * @PANGO_BIDI_TYPE_ET: European Number Terminator - * @PANGO_BIDI_TYPE_AN: Arabic Number - * @PANGO_BIDI_TYPE_CS: Common Number Separator - * @PANGO_BIDI_TYPE_NSM: Nonspacing Mark - * @PANGO_BIDI_TYPE_BN: Boundary Neutral - * @PANGO_BIDI_TYPE_B: Paragraph Separator - * @PANGO_BIDI_TYPE_S: Segment Separator - * @PANGO_BIDI_TYPE_WS: Whitespace - * @PANGO_BIDI_TYPE_ON: Other Neutrals - * @PANGO_BIDI_TYPE_LRI: Left-to-Right isolate. Since 1.48.6 - * @PANGO_BIDI_TYPE_RLI: Right-to-Left isolate. Since 1.48.6 - * @PANGO_BIDI_TYPE_FSI: First strong isolate. Since 1.48.6 - * @PANGO_BIDI_TYPE_PDI: Pop directional isolate. Since 1.48.6 - * - * `PangoBidiType` represents the bidirectional character - * type of a Unicode character. - * - * The values in this enumeration are specified by the - * [Unicode bidirectional algorithm](http://www.unicode.org/reports/tr9/). - * - * Since: 1.22 - * Deprecated: 1.44: Use fribidi for this information - **/ -typedef enum { - /* Strong types */ - PANGO_BIDI_TYPE_L, - PANGO_BIDI_TYPE_LRE, - PANGO_BIDI_TYPE_LRO, - PANGO_BIDI_TYPE_R, - PANGO_BIDI_TYPE_AL, - PANGO_BIDI_TYPE_RLE, - PANGO_BIDI_TYPE_RLO, - - /* Weak types */ - PANGO_BIDI_TYPE_PDF, - PANGO_BIDI_TYPE_EN, - PANGO_BIDI_TYPE_ES, - PANGO_BIDI_TYPE_ET, - PANGO_BIDI_TYPE_AN, - PANGO_BIDI_TYPE_CS, - PANGO_BIDI_TYPE_NSM, - PANGO_BIDI_TYPE_BN, - - /* Neutral types */ - PANGO_BIDI_TYPE_B, - PANGO_BIDI_TYPE_S, - PANGO_BIDI_TYPE_WS, - PANGO_BIDI_TYPE_ON, - - /* Explicit formatting */ - PANGO_BIDI_TYPE_LRI, - PANGO_BIDI_TYPE_RLI, - PANGO_BIDI_TYPE_FSI, - PANGO_BIDI_TYPE_PDI -} PangoBidiType; - -PANGO_DEPRECATED_IN_1_44 -PangoBidiType pango_bidi_type_for_unichar (gunichar ch) G_GNUC_CONST; - -PANGO_DEPRECATED_IN_1_44 -PangoDirection pango_unichar_direction (gunichar ch) G_GNUC_CONST; -PANGO_DEPRECATED_IN_1_44 -PangoDirection pango_find_base_dir (const gchar *text, - gint length); - -PANGO_DEPRECATED_IN_1_30_FOR(g_unichar_get_mirror_char) -gboolean pango_get_mirror_char (gunichar ch, - gunichar *mirrored_ch); -#endif - -G_END_DECLS - -#endif /* __PANGO_BIDI_TYPE_H__ */ diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 753a8a6e..07196fdb 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -88,6 +88,7 @@ #include "pango-layout-private.h" #include "pango-attributes-private.h" #include "pango-font-private.h" +#include "pango-utils-internal.h" typedef struct _ItemProperties ItemProperties; diff --git a/pango/pango-script.h b/pango/pango-script.h index 3877989c..86993d58 100644 --- a/pango/pango-script.h +++ b/pango/pango-script.h @@ -25,7 +25,6 @@ #include <glib-object.h> #include <pango/pango-version-macros.h> -#include <pango/pango-language.h> G_BEGIN_DECLS @@ -323,6 +322,8 @@ gboolean pango_script_iter_next (PangoScriptIter *iter); PANGO_AVAILABLE_IN_1_4 void pango_script_iter_free (PangoScriptIter *iter); +#include <pango/pango-language.h> + PANGO_AVAILABLE_IN_1_4 PangoLanguage *pango_script_get_sample_language (PangoScript script) G_GNUC_PURE; diff --git a/pango/pango-types.h b/pango/pango-types.h index 94db77d7..ae27630d 100644 --- a/pango/pango-types.h +++ b/pango/pango-types.h @@ -228,11 +228,11 @@ void pango_extents_to_pixels (PangoRectangle *inclusive, PangoRectangle *nearest); +#include <pango/pango-direction.h> #include <pango/pango-gravity.h> #include <pango/pango-language.h> #include <pango/pango-matrix.h> #include <pango/pango-script.h> -#include <pango/pango-bidi-type.h> G_END_DECLS diff --git a/pango/pango-utils-internal.h b/pango/pango-utils-internal.h index 0bc355e0..904dd08b 100644 --- a/pango/pango-utils-internal.h +++ b/pango/pango-utils-internal.h @@ -25,6 +25,7 @@ #include <stdio.h> #include <glib.h> #include <pango/pango-font.h> +#include <pango/pango-direction.h> G_BEGIN_DECLS @@ -43,6 +44,8 @@ gboolean pango_parse_flags (GType type, char *_pango_trim_string (const char *str); +PangoDirection pango_find_base_dir (const char *text, + int length); G_END_DECLS diff --git a/pango/pango-utils.c b/pango/pango-utils.c index aa292938..80b18061 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -320,49 +320,6 @@ pango_parse_flags (GType type, return ret; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -/** - * pango_find_base_dir: - * @text: the text to process. Must be valid UTF-8 - * @length: length of @text in bytes (may be -1 if @text is nul-terminated) - * - * Searches a string the first character that has a strong - * direction, according to the Unicode bidirectional algorithm. - * - * Return value: The direction corresponding to the first strong character. - * If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned. - * - * Since: 1.4 - */ -PangoDirection -pango_find_base_dir (const gchar *text, - gint length) -{ - PangoDirection dir = PANGO_DIRECTION_NEUTRAL; - const gchar *p; - - g_return_val_if_fail (text != NULL || length == 0, PANGO_DIRECTION_NEUTRAL); - - p = text; - while ((length < 0 || p < text + length) && *p) - { - gunichar wc = g_utf8_get_char (p); - - dir = pango_unichar_direction (wc); - - if (dir != PANGO_DIRECTION_NEUTRAL) - break; - - p = g_utf8_next_char (p); - } - - return dir; -} - -#pragma GCC diagnostic pop - /** * pango_is_zero_width: * @ch: a Unicode character diff --git a/pango/pango.h b/pango/pango.h index a6220a8c..39d59455 100644 --- a/pango/pango.h +++ b/pango/pango.h @@ -23,7 +23,6 @@ #define __PANGO_H__ #include <pango/pango-attributes.h> -#include <pango/pango-bidi-type.h> #include <pango/pango-break.h> #include <pango/pango-color.h> #include <pango/pango-context.h> diff --git a/tests/test-bidi.c b/tests/test-bidi.c index eb99abbf..2b19c832 100644 --- a/tests/test-bidi.c +++ b/tests/test-bidi.c @@ -25,91 +25,6 @@ static PangoContext *context; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -static void -test_mirror_char (void) -{ - /* just some samples */ - struct { - gunichar a; - gunichar b; - } tests[] = { - { '(', ')' }, - { '<', '>' }, - { '[', ']' }, - { '{', '}' }, - { 0x00ab, 0x00bb }, - { 0x2045, 0x2046 }, - { 0x226e, 0x226f }, - }; - - for (int i = 0; i < G_N_ELEMENTS (tests); i++) - { - gboolean ret; - gunichar ch; - - ret = pango_get_mirror_char (tests[i].a, &ch); - g_assert_true (ret); - g_assert_true (ch == tests[i].b); - ret = pango_get_mirror_char (tests[i].b, &ch); - g_assert_true (ret); - g_assert_true (ch == tests[i].a); - } -} - -static void -test_bidi_type_for_unichar (void) -{ - /* one representative from each class we support */ - g_assert_true (pango_bidi_type_for_unichar ('a') == PANGO_BIDI_TYPE_L); - g_assert_true (pango_bidi_type_for_unichar (0x202a) == PANGO_BIDI_TYPE_LRE); - g_assert_true (pango_bidi_type_for_unichar (0x202d) == PANGO_BIDI_TYPE_LRO); - g_assert_true (pango_bidi_type_for_unichar (0x05d0) == PANGO_BIDI_TYPE_R); - g_assert_true (pango_bidi_type_for_unichar (0x0627) == PANGO_BIDI_TYPE_AL); - g_assert_true (pango_bidi_type_for_unichar (0x202b) == PANGO_BIDI_TYPE_RLE); - g_assert_true (pango_bidi_type_for_unichar (0x202e) == PANGO_BIDI_TYPE_RLO); - g_assert_true (pango_bidi_type_for_unichar (0x202c) == PANGO_BIDI_TYPE_PDF); - g_assert_true (pango_bidi_type_for_unichar ('0') == PANGO_BIDI_TYPE_EN); - g_assert_true (pango_bidi_type_for_unichar ('+') == PANGO_BIDI_TYPE_ES); - g_assert_true (pango_bidi_type_for_unichar ('#') == PANGO_BIDI_TYPE_ET); - g_assert_true (pango_bidi_type_for_unichar (0x601) == PANGO_BIDI_TYPE_AN); - g_assert_true (pango_bidi_type_for_unichar (',') == PANGO_BIDI_TYPE_CS); - g_assert_true (pango_bidi_type_for_unichar (0x0301) == PANGO_BIDI_TYPE_NSM); - g_assert_true (pango_bidi_type_for_unichar (0x200d) == PANGO_BIDI_TYPE_BN); - g_assert_true (pango_bidi_type_for_unichar (0x2029) == PANGO_BIDI_TYPE_B); - g_assert_true (pango_bidi_type_for_unichar (0x000b) == PANGO_BIDI_TYPE_S); - g_assert_true (pango_bidi_type_for_unichar (' ') == PANGO_BIDI_TYPE_WS); - g_assert_true (pango_bidi_type_for_unichar ('!') == PANGO_BIDI_TYPE_ON); - /* these are new */ - g_assert_true (pango_bidi_type_for_unichar (0x2066) == PANGO_BIDI_TYPE_LRI); - g_assert_true (pango_bidi_type_for_unichar (0x2067) == PANGO_BIDI_TYPE_RLI); - g_assert_true (pango_bidi_type_for_unichar (0x2068) == PANGO_BIDI_TYPE_FSI); - g_assert_true (pango_bidi_type_for_unichar (0x2069) == PANGO_BIDI_TYPE_PDI); -} - -static void -test_unichar_direction (void) -{ - struct { - gunichar ch; - PangoDirection dir; - } tests[] = { - { 'a', PANGO_DIRECTION_LTR }, - { '0', PANGO_DIRECTION_NEUTRAL }, - { '.', PANGO_DIRECTION_NEUTRAL }, - { '(', PANGO_DIRECTION_NEUTRAL }, - { 0x05d0, PANGO_DIRECTION_RTL }, - }; - - for (int i = 0; i < G_N_ELEMENTS (tests); i++) - { - g_assert_true (pango_unichar_direction (tests[i].ch) == tests[i].dir); - } -} - -G_GNUC_END_IGNORE_DEPRECATIONS - static void test_bidi_embedding_levels (void) { @@ -464,9 +379,6 @@ main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); - g_test_add_func ("/bidi/mirror-char", test_mirror_char); - g_test_add_func ("/bidi/type-for-unichar", test_bidi_type_for_unichar); - g_test_add_func ("/bidi/unichar-direction", test_unichar_direction); g_test_add_func ("/bidi/embedding-levels", test_bidi_embedding_levels); g_test_add_func ("/bidi/move-cursor-line", test_move_cursor_line); g_test_add_func ("/bidi/move-cursor-para", test_move_cursor_para); |