From: Han-Wen Nienhuys Date: Wed, 11 Oct 2006 23:20:07 +0000 (+0000) Subject: * lily/general-scheme.cc (LY_DEFINE): elucidate docstring. X-Git-Tag: release/2.10.0-2~200 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=272196a953f0b39de8da914f47e9daa8e93925b0;p=lilypond.git * lily/general-scheme.cc (LY_DEFINE): elucidate docstring. * scm/define-markup-commands.scm (tied-lyric): new function: split string along ~ and reattach with U+203F (tie character) and negative space. * scm/output-lib.scm (lyric-text::calc-text): new function. * lily/lyric-engraver.cc (process_music): don't set 'text. * scm/output-lib.scm (string-finger::calc-text): new function (lyric-text::print): new function. * scm/define-grobs.scm (all-grob-descriptions): add StringFinger --- diff --git a/ChangeLog b/ChangeLog index 680ceb6ac9..cc035348b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,17 @@ 2006-10-12 Han-Wen Nienhuys + * lily/general-scheme.cc (LY_DEFINE): elucidate docstring. + + * scm/define-markup-commands.scm (tied-lyric): new function: split + string along ~ and reattach with U+203F (tie character) and + negative space. + + * scm/output-lib.scm (lyric-text::calc-text): new function. + + * lily/lyric-engraver.cc (process_music): don't set 'text. + * scm/output-lib.scm (string-finger::calc-text): new function + (lyric-text::print): new function. * lily/new-fingering-engraver.cc (add_fingering): refactor; make generic for fingering & string number. Use for string-finger. diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index 5beda8355e..6b96729d42 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -236,7 +236,7 @@ LY_DEFINE (ly_output_formats, "ly:output-formats", LY_DEFINE (ly_wchar_to_utf_8, "ly:wide-char->utf-8", 1, 0, 0, (SCM wc), - "Encode the Unicode codepoint @var{wc} as UTF-8") + "Encode the Unicode codepoint @var{wc}, an integer, as UTF-8") { char buf[5]; diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index e11f4ec222..7ef5dde889 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -69,7 +69,6 @@ Lyric_engraver::process_music () else { text_ = make_item ("LyricText", event_->self_scm ()); - text_->set_property ("text", text); } } } diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 5dc860bd27..84078d3888 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -899,9 +899,11 @@ lyric-hyphen-interface spacing-interface)) )) )) + (LyricText . ( - (stencil . ,ly:text-interface::print) + (stencil . ,lyric-text::print) + (text . ,lyric-text::calc-text) (X-offset . ,ly:self-alignment-interface::aligned-on-x-parent) (self-alignment-X . 0) (word-space . 0.6) diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index e6d16ce558..960b78031d 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -274,11 +274,38 @@ grestore ;; basic formatting. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define (list-join lst intermediate) + (reduce (lambda (elt prev) + (if (pair? prev) (cons elt (cons intermediate prev)) + (list elt intermediate prev))) '() lst)) + + (define-markup-command (simple layout props str) (string?) "A simple text string; @code{\\markup @{ foo @}} is equivalent with @code{\\markup @{ \\simple #\"foo\" @}}." (interpret-markup layout props str)) +(define-markup-command (tied-lyric layout props str) (string?) + + "Like simple-markup, but use tie characters for ~ tilde symbols." + + (if (string-contains str "~") + (let* + ((parts (string-split str #\~)) + (tie-str (ly:wide-char->utf-8 #x203f)) + (joined (list-join parts tie-str)) + (join-stencil (interpret-markup layout props tie-str)) + ) + + (interpret-markup layout + (prepend-alist-chain + 'word-space + (/ (interval-length (ly:stencil-extent join-stencil X)) -4) + props) + (make-line-markup joined))) + ;(map (lambda (s) (interpret-markup layout props s)) parts)) + (interpret-markup layout props str))) + ;; TODO: use font recoding. ;; (make-line-markup diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 1558e76118..413d99b540 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -431,3 +431,24 @@ centered, X==1 is at the right, X == -1 is at the left." START STOP )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; lyrics + +(define-public (lyric-text::print grob) + "Allow interpretation of tildes as lyric tieing marks." + + (let* + ((text (ly:grob-property grob 'text)) + (layout (ly:grob-layout grob)) + (defs (ly:output-def-lookup layout 'text-font-defaults)) + (props (ly:grob-alist-chain grob defs))) + + (ly:text-interface::interpret-markup layout + props + (if (string? text) + (make-tied-lyric-markup text) + text)))) + +(define-public (lyric-text::calc-text grob) + (ly:event-property (event-cause grob) 'text))