[pango/wip/khaled/fribidi: 1/2] Use the new FriBiDi API when available
- From: Khaled Hosny <khaledh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/wip/khaled/fribidi: 1/2] Use the new FriBiDi API when available
- Date: Tue, 14 Nov 2017 21:00:15 +0000 (UTC)
commit 183f48098ac16ac25375392dfed68530b3d18fe4
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 | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c
index f49a4e2..532613d 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:
@@ -147,6 +150,9 @@ pango_log2vis_get_embedding_levels (const gchar *text,
{
glong n_chars, i;
FriBidiCharType *types;
+#ifdef USE_FRIBIDI_EX_API
+ FriBidiBracketType *brackets;
+#endif
FriBidiLevel max_level;
const char *p;
@@ -156,17 +162,32 @@ pango_log2vis_get_embedding_levels (const gchar *text,
n_chars = g_utf8_strlen (text, length);
types = g_new (FriBidiCharType, n_chars);
+#ifdef USE_FRIBIDI_EX_API
+ brackets = 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);
types[i] = fribidi_get_bidi_type (ch);
+#ifdef USE_FRIBIDI_EX_API
+ if (types[i] != FRIBIDI_TYPE_ON)
+ brackets[i] = FRIBIDI_NO_BRACKET;
+ else
+ brackets[i] = fribidi_get_bracket (ch);
+#endif
}
+#ifdef USE_FRIBIDI_EX_API
+ max_level = fribidi_get_par_embedding_levels_ex (types, brackets, n_chars,
+ &fribidi_base_dir,
+ (FriBidiLevel*)embedding_levels_list);
+#else
max_level = fribidi_get_par_embedding_levels (types, n_chars,
&fribidi_base_dir,
(FriBidiLevel*)embedding_levels_list);
+#endif
if (max_level == 0)
{
/* fribidi_get_par_embedding_levels failed, what should we do here? */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]