From 50b6b59d02947bf17252c402deff112c2071edc8 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 3 Mar 2014 18:04:19 +0000 Subject: [PATCH] text: Discover the direction of the contents We should set the direction on the PangoContext when creating a PangoLayout based on a best effort between the contents of the text itself and the text direction of the widget, in case that fails. https://bugzilla.gnome.org/show_bug.cgi?id=705779 --- clutter/clutter-text.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 90565ff98..17f3500db 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -528,7 +528,30 @@ clutter_text_create_layout_no_cache (ClutterText *text, pango_attr_list_unref (tmp_attrs); } else - pango_layout_set_text (layout, contents, contents_len); + { + PangoDirection pango_dir; + + if (priv->password_char != 0) + pango_dir = PANGO_DIRECTION_NEUTRAL; + else + pango_dir = pango_find_base_dir (contents, contents_len); + + if (pango_dir == PANGO_DIRECTION_NEUTRAL) + { + ClutterTextDirection text_dir; + + text_dir = clutter_actor_get_text_direction (CLUTTER_ACTOR (text)); + + if (text_dir == CLUTTER_TEXT_DIRECTION_RTL) + pango_dir = PANGO_DIRECTION_RTL; + else + pango_dir = PANGO_DIRECTION_LTR; + } + + pango_context_set_base_dir (clutter_actor_get_pango_context (CLUTTER_ACTOR (text)), pango_dir); + + pango_layout_set_text (layout, contents, contents_len); + } /* This will merge the markup attributes and the attributes * property if needed */