From: Patrick McCarty Date: Sun, 13 Dec 2009 09:17:22 +0000 (-0800) Subject: Pango: Do not assume markup is only LTR or RTL. X-Git-Tag: release/2.13.10-1~193 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6225b96c34d642bab59cf9282e240d0e7d6542f2;p=lilypond.git Pango: Do not assume markup is only LTR or RTL. 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. --- 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 ())