2006-10-12 Han-Wen Nienhuys <hanwen@lilypond.org>
+ * 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.
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];
else
{
text_ = make_item ("LyricText", event_->self_scm ());
- text_->set_property ("text", text);
}
}
}
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)
;; 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
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))