]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/define-markup-commands.scm (wordwrap-string): use
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 25 Aug 2005 13:37:00 +0000 (13:37 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 25 Aug 2005 13:37:00 +0000 (13:37 +0000)
text-direction
(wordwrap-stencils): idem.
(line): idem..
(fill-line): idem.

* scm/define-grob-properties.scm (all-user-grob-properties): add
text-direction.

ChangeLog
Documentation/topdocs/NEWS.tely
THANKS
lily/pango-font.cc
lily/text-interface.cc
scm/define-grob-properties.scm
scm/define-markup-commands.scm

index 142e21a069e562d74ee8eab849679bc590d24b6b..e214fa8de94370b3c16920f6a9079a80d995f32c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-08-25  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/define-markup-commands.scm (wordwrap-string): use
+       text-direction
+       (wordwrap-stencils): idem.
+       (line): idem..
+       (fill-line): idem.
+
+       * scm/define-grob-properties.scm (all-user-grob-properties): add
+       text-direction.
+
 2005-08-25  Nicolas Sceaux  <nicolas.sceaux@free.fr>
 
        * lily/lily-parser.cc (Lily_parser): also copy output_basename_
@@ -30,7 +41,7 @@
 
        * lily/vertical-align-engraver.cc (process_music): call
        Align_interface::set_axis(). This forces #'elements to be ordered,
-       preventing random vertical reordering  of staves.
+       preventing random vertical reordering of staves.
 
        * scm/define-grob-interfaces.scm (dynamic-line-spanner-interface):
        add avoid-slur property. 
index 05d533d416b51ce75f9f15d03d4fefe16d0a65d0..fdc89c82ece3ba1605e9a201d0177745a8706966 100644 (file)
@@ -47,6 +47,14 @@ This document is also available in @uref{NEWS.pdf,PDF}.
 @itemize @bullet
 
 
+@item
+The order of words in @code{\markup} commands may now be reversed by
+setting the @code{text-direction} property. This is useful for
+Right-to-Left languages like Hebrew.
+
+This feature was sponsored by Aaron Mehl.
+
+
 @item
 Texts over multi measure rests now stretch corresponding measure.
 
diff --git a/THANKS b/THANKS
index e3f24e87da86a982d15989f321eef054b9404898..fd6f5b548bff3eda120172ae1a9f29c55756114d 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -21,6 +21,7 @@ Yoshinobu Ishizaki
 
 SPONSORS
 
+Aaron Mehl
 Jay Hamilton
 Jamie Bullock
 D. Josiah Boothby
index f2f5af875566020976ef1eeac6a8d42307a4627f..384593bd0d1fa971c09717d51fc628b5c1ec7338 100644 (file)
@@ -221,6 +221,9 @@ Pango_font::text_stencil (String str) const
 
       Stencil item_stencil = pango_item_string_stencil (item, str, x);
 
+      /*
+      UGH. Is this correct for bidi? 
+      */
       x = item_stencil.extent (X_AXIS)[RIGHT];
 
       dest.add_stencil (item_stencil);
index 18ec49f8746fab8bddb11a1b14d92c79caa53856..cb0b6e1ab2ab70a2ae3ac21ff5812a064cdee637 100644 (file)
@@ -92,5 +92,9 @@ Text_interface::is_markup (SCM x)
 
 ADD_INTERFACE (Text_interface, "text-interface",
               "A scheme markup text, see @usermanref{Text markup}.",
-              "baseline-skip direction text word-space");
+              "baseline-skip "
+              "text "
+              "word-space "
+              "text-direction "
+              );
 
index a3c637534ab8387eb06c12fdcba5190b3ff0d542..10d401489e8e4228087121d9712b969a638550ab 100644 (file)
@@ -461,6 +461,9 @@ typeset. Valid choices depend on the @code{print-function} that is
 reading this property.")
      (text ,markup? "Text markup.  See @usermanref{Text markup}.")
 ;;FIXME -- Should both be the same?
+     (text-direction ,ly:dir? "This controls the ordering of the
+words. The default RIGHT is for roman text. Arabic or hebrew should
+use LEFT.")
      (thick-thickness ,number? "Bar line thickness, measured in
 @code{linethickness}.")
      (thickness ,number? "Bar line thickness, measured in
index 8bcdd566610ad915cce1d6dea13ecea686bc322a..c1194e36b903096e4df364f405eb921339b68d15 100644 (file)
@@ -344,6 +344,7 @@ gsave /ecrm10 findfont
                     (interval-length (ly:stencil-extent stc X))))
               stencils))
         (text-width (apply + text-widths))
+        (text-dir (chain-assoc-get 'text-direction props RIGHT))
         (word-count (length stencils))
         (word-space (chain-assoc-get 'word-space props))
         (line-width (chain-assoc-get 'linewidth props))
@@ -358,12 +359,12 @@ gsave /ecrm10 findfont
                                        (- line-width text-width)))
                        (else 
                                (get-fill-space word-count line-width text-widths))))
-     (fill-space-normal
-       (map (lambda (x)
-               (if (< x word-space)
-                       word-space
-                               x))
-                       fill-space))
+        (fill-space-normal
+         (map (lambda (x)
+                (if (< x word-space)
+                    word-space
+                    x))
+              fill-space))
                                        
         (line-stencils (if (= word-count 1)
                            (list
@@ -372,24 +373,35 @@ gsave /ecrm10 findfont
                             point-stencil)
                            stencils)))
 
+    (if (= text-dir LEFT)
+       (set! line-stencils (reverse line-stencils)))
+
     (if (null? (remove ly:stencil-empty? orig-stencils))
        empty-stencil
-       (stack-stencils-padding-list X RIGHT fill-space-normal line-stencils))))
+       (stack-stencils-padding-list X
+                                    RIGHT fill-space-normal line-stencils))))
        
 (def-markup-command (line layout props args) (markup-list?)
   "Put @var{args} in a horizontal line.  The property @code{word-space}
 determines the space between each markup in @var{args}."
   (let*
       ((stencils (map (lambda (m) (interpret-markup layout props m)) args))
-       (space    (chain-assoc-get 'word-space props)))
+       (space    (chain-assoc-get 'word-space props))
+       (text-dir (chain-assoc-get 'text-direction props RIGHT)) 
+       )
+
+    
+    (if (= text-dir LEFT)
+       (set! stencils (reverse stencils)))
+    
 
-  (stack-stencil-line
-   space
-   (remove ly:stencil-empty? stencils))))
+    (stack-stencil-line
+     space
+     (remove ly:stencil-empty? stencils))))
 
 
 (define (wordwrap-stencils stencils
-                          justify base-space line-width)
+                          justify base-space line-width text-dir)
   
   "Perform simple wordwrap, return stencil of each line."
   
@@ -445,7 +457,9 @@ determines the space between each markup in @var{args}."
 
           (line (stack-stencil-line
                  line-word-space
-                 (reverse line-stencils))))
+                 (if (= text-dir RIGHT)
+                     (reverse line-stencils)
+                     line-stencils))))
 
        (if (pair? (cdr line-break))
            (loop (cons line lines)
@@ -462,10 +476,12 @@ determines the space between each markup in @var{args}."
       ((baseline-skip (chain-assoc-get 'baseline-skip props))
        (line-width (chain-assoc-get 'linewidth props))
        (word-space (chain-assoc-get 'word-space props))
+       (text-dir (chain-assoc-get 'text-direction props RIGHT)) 
        (lines (wordwrap-stencils
               (remove ly:stencil-empty?
                       (map (lambda (m) (interpret-markup layout props m)) args))
-              justify word-space  line-width)
+              justify word-space line-width
+              text-dir)
               ))
 
     (stack-lines DOWN 0.0 baseline-skip lines)))
@@ -490,6 +506,7 @@ linewidth, where X is the number of staff spaces."
        (word-space (chain-assoc-get 'word-space props))
        (para-strings (regexp-split arg "\n[ \t\n]*\n[ \t\n]*"))
        
+       (text-dir (chain-assoc-get 'text-direction props RIGHT)) 
        (list-para-words (map (lambda (str)
                               (regexp-split str "[ \t\n]+"))
                             para-strings))
@@ -502,7 +519,9 @@ linewidth, where X is the number of staff spaces."
                                        (interpret-markup layout props x))
                                      words)))
                               (lines (wordwrap-stencils stencils
-                                                        justify word-space line-width)))
+                                                        justify word-space
+                                                        line-width text-dir
+                                                        )))
 
                            lines))