From 6225b96c34d642bab59cf9282e240d0e7d6542f2 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Sun, 13 Dec 2009 01:17:22 -0800 Subject: [PATCH] Pango: Do not assume markup is only LTR or RTL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current code assumes that markup is either LTR or RTL. But it could be both. For example \markup { "h א" } should be displayed as written, but LilyPond displays this string as "אh" This patch fixes that issue. With pango_itemize(), Pango automatically (and correctly) divides the markup into sections that are intended to be processed by the Unicode Bidirectional Algorithm. Pango also handles the RTL character reordering, within each of these sections, if necessary. For now, until we implement the Unicode Bidirectional Algorithm, or another solution is found, simply place each section in order from left to right. --- lily/pango-font.cc | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 4938d139ef..644c21c433 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -322,27 +322,19 @@ Pango_font::text_stencil (string str, Real last_x = 0.0; - Direction text_dir = RIGHT; - for (GList *p = items; p; p = p->next) - { - PangoItem *item = (PangoItem *) p->data; - if (item->analysis.level == PANGO_DIRECTION_RTL) - text_dir = LEFT; - } - + /* + FIXME: The Unicode Bidirectional Algorithm needs to be + implemented here. Right now, a simplistic approach is taken: + a left-to-right ordering of each item in the GList. + */ for (GList *ptr = items; ptr; ptr = ptr->next) { PangoItem *item = (PangoItem *) ptr->data; Stencil item_stencil = pango_item_string_stencil (item, str, tight); - if (text_dir == RIGHT) - { - item_stencil.translate_axis (last_x, X_AXIS); - last_x = item_stencil.extent (X_AXIS)[RIGHT]; - } - else if (text_dir == LEFT) - dest.translate_axis (item_stencil.extent (X_AXIS)[RIGHT], X_AXIS); + item_stencil.translate_axis (last_x, X_AXIS); + last_x = item_stencil.extent (X_AXIS)[RIGHT]; #if 0 // Check extents. if (!item_stencil.extent_box ()[X_AXIS].is_empty ()) -- 2.39.2