[gtk/wip/jimmac/adwaita-3-32] gtk: Add a copy of some deprecated pango api
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/jimmac/adwaita-3-32] gtk: Add a copy of some deprecated pango api
- Date: Mon, 4 Feb 2019 14:09:55 +0000 (UTC)
commit 13c126b277697047114801ee4559803894693a2d
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 31 14:05:54 2019 -0500
gtk: Add a copy of some deprecated pango api
We use pango_find_base_dir() in a few places, and
this api has been deprecated.
gtk/gtkpango.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkpango.h | 3 +++
2 files changed, 47 insertions(+)
---
diff --git a/gtk/gtkpango.c b/gtk/gtkpango.c
index 63d445f385..aaac4cc631 100644
--- a/gtk/gtkpango.c
+++ b/gtk/gtkpango.c
@@ -25,6 +25,7 @@
#include "config.h"
#include "gtkpango.h"
#include <pango/pangocairo.h>
+#include <fribidi.h>
#include "gtkintl.h"
#define GTK_TYPE_FILL_LAYOUT_RENDERER (_gtk_fill_layout_renderer_get_type())
@@ -1321,3 +1322,46 @@ _gtk_pango_attr_list_merge (PangoAttrList *into,
return into;
}
+
+PangoDirection
+_gtk_pango_unichar_direction (gunichar ch)
+{
+ FriBidiCharType fribidi_ch_type;
+
+ G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
+
+ fribidi_ch_type = fribidi_get_bidi_type (ch);
+
+ if (!FRIBIDI_IS_STRONG (fribidi_ch_type))
+ return PANGO_DIRECTION_NEUTRAL;
+ else if (FRIBIDI_IS_RTL (fribidi_ch_type))
+ return PANGO_DIRECTION_RTL;
+ else
+ return PANGO_DIRECTION_LTR;
+}
+
+PangoDirection
+_gtk_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 = _gtk_pango_unichar_direction (wc);
+
+ if (dir != PANGO_DIRECTION_NEUTRAL)
+ break;
+
+ p = g_utf8_next_char (p);
+ }
+
+ return dir;
+}
+
diff --git a/gtk/gtkpango.h b/gtk/gtkpango.h
index 0d6e6c00d0..388e364858 100644
--- a/gtk/gtkpango.h
+++ b/gtk/gtkpango.h
@@ -82,6 +82,9 @@ gchar *_gtk_pango_get_text_after (PangoLayout *layout,
PangoAttrList *_gtk_pango_attr_list_merge (PangoAttrList *into,
PangoAttrList *from);
+PangoDirection _gtk_pango_find_base_dir (const gchar *text,
+ gint length);
+
G_END_DECLS
#endif /* __GTK_PANGO_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]