]> git.donarmstrong.com Git - lilypond.git/commitdiff
Pango: Do not assume markup is only LTR or RTL.
authorPatrick McCarty <pnorcks@gmail.com>
Sun, 13 Dec 2009 09:17:22 +0000 (01:17 -0800)
committerPatrick McCarty <pnorcks@gmail.com>
Sun, 13 Dec 2009 09:56:55 +0000 (01:56 -0800)
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

index 4938d139efc4bf1c233d0326d2d47d4b56ccf33e..644c21c433361d3b6a2b05b7ec0f3cd132132a7c 100644 (file)
@@ -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 ())