[pango/wip/khaled/fribidi: 8/8] Use the new FriBiDi API when available



commit 22ef22e75d45c2f1f6175b09737ef2fa84d8c04c
Author: Khaled Hosny <khaledhosny eglug org>
Date:   Tue Nov 14 15:55:14 2017 +0200

    Use the new FriBiDi API when available

 pango/pango-bidi-type.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c
index c915ea0..29f6888 100644
--- a/pango/pango-bidi-type.c
+++ b/pango/pango-bidi-type.c
@@ -46,6 +46,9 @@
 #include "pango-bidi-type.h"
 #include "pango-utils.h"
 
+#if (FRIBIDI_MINOR_VERSION >= 19) && (FRIBIDI_MICRO_VERSION > 7)
+#define USE_FRIBIDI_EX_API
+#endif
 
 /**
  * pango_bidi_type_for_unichar:
@@ -126,6 +129,9 @@ pango_log2vis_get_embedding_levels (const gchar    *text,
   const gchar *p;
   FriBidiParType fribidi_base_dir;
   FriBidiCharType *bidi_types;
+#ifdef USE_FRIBIDI_EX_API
+  FriBidiBracketType *bracket_types;
+#endif
   FriBidiLevel max_level;
 
 
@@ -155,17 +161,33 @@ pango_log2vis_get_embedding_levels (const gchar    *text,
   n_chars = g_utf8_strlen (text, length);
 
   bidi_types = g_new (FriBidiCharType, n_chars);
+#ifdef USE_FRIBIDI_EX_API
+  bracket_types = g_new (FriBidiBracketType, n_chars);
+#endif
   embedding_levels_list = g_new (guint8, n_chars);
 
   for (i = 0, p = text; p < text + length; p = g_utf8_next_char(p), i++)
     {
       gunichar ch = g_utf8_get_char (p);
       bidi_types[i] = fribidi_get_bidi_type (ch);
+#ifdef USE_FRIBIDI_EX_API
+      if (G_UNLIKELY(bidi_types[i] == FRIBIDI_TYPE_ON))
+        bracket_types[i] = fribidi_get_bracket (ch);
+      else
+        bracket_types[i] = FRIBIDI_NO_BRACKET;
+#endif
     }
 
+#ifdef USE_FRIBIDI_EX_API
+  max_level = fribidi_get_par_embedding_levels_ex (bidi_types, bracket_types, n_chars,
+                                                  &fribidi_base_dir,
+                                                  (FriBidiLevel*)embedding_levels_list);
+  g_free (bracket_types);
+#else
   max_level = fribidi_get_par_embedding_levels (bidi_types, n_chars,
                                                &fribidi_base_dir,
                                                (FriBidiLevel*)embedding_levels_list);
+#endif
 
   g_free (bidi_types);
 


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