From: Han-Wen Nienhuys Date: Thu, 25 Aug 2005 13:37:00 +0000 (+0000) Subject: * scm/define-markup-commands.scm (wordwrap-string): use X-Git-Tag: release/2.7.8~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=744fe80833545434da9955b46a5d3c896931163e;p=lilypond.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 142e21a069..e214fa8de9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-08-25 Han-Wen Nienhuys + + * 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 * 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. diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index 05d533d416..fdc89c82ec 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -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 e3f24e87da..fd6f5b548b 100644 --- a/THANKS +++ b/THANKS @@ -21,6 +21,7 @@ Yoshinobu Ishizaki SPONSORS +Aaron Mehl Jay Hamilton Jamie Bullock D. Josiah Boothby diff --git a/lily/pango-font.cc b/lily/pango-font.cc index f2f5af8755..384593bd0d 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -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); diff --git a/lily/text-interface.cc b/lily/text-interface.cc index 18ec49f874..cb0b6e1ab2 100644 --- a/lily/text-interface.cc +++ b/lily/text-interface.cc @@ -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 " + ); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index a3c637534a..10d401489e 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -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 diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 8bcdd56661..c1194e36b9 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -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))