summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2014-03-03 18:04:19 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2014-03-03 23:42:33 +0000
commit50b6b59d02947bf17252c402deff112c2071edc8 (patch)
treebfbf311b45687ec386f584359583473efb7a52ee
parentc42aa42361ef12f2b331fe10db77510f2aada67c (diff)
downloadclutter-50b6b59d02947bf17252c402deff112c2071edc8.tar.gz
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
-rw-r--r--clutter/clutter-text.c25
1 files changed, 24 insertions, 1 deletions
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 */