[pango/pango2: 14/168] Drop deprecated bidi api




commit 11df4292b6d5b1d4231320789098734a40a84436
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 10 13:46:46 2022 -0500

    Drop deprecated bidi api

 pango/meson.build            |   1 -
 pango/pango-bidi-type.c      | 121 +++++++++----------------------------------
 pango/pango-bidi-type.h      | 117 -----------------------------------------
 pango/pango-layout.c         |   1 +
 pango/pango-types.h          |   2 +-
 pango/pango-utils-internal.h |   3 ++
 pango/pango-utils.c          |  43 ---------------
 pango/pango.h                |   1 -
 tests/test-bidi.c            |  88 -------------------------------
 9 files changed, 30 insertions(+), 347 deletions(-)
---
diff --git a/pango/meson.build b/pango/meson.build
index 6b4ab481..7cd4b216 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-layout.c b/pango/pango-layout.c
index a3c75711..5051a2f4 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-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 ba578ba8..509f110d 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)
 {
@@ -465,9 +380,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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]