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.
This commit is contained in:
parent
148650c23a
commit
13c126b277
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user