lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: markup in lyrics


From: Jan-Peter Voigt
Subject: Re: markup in lyrics
Date: Wed, 05 Oct 2011 09:48:43 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Lightning/1.0b2 Thunderbird/3.1.15

Hello list,

for the simple case of italic lyrics, the answer withe override/revert is already given. But I just wanted to point out another possibility for more complex markups in lyrics: In the following snippet I define a function to create music functions, that wraps all lyric syllables in another markup. The actual syllable is given in a property 'lyric:text, so \markup { \fromproperty #'lyric:text } prints the lyrics unmodified. If there are only few places to modify font-shape or font-size, I'd recommend the override/revert solution (you still might have a function with an \override $mus \revert construct). But if you have another markup command, that is not covered by the standard LyricText-properties, you can use this function. And you can have a central place to define, how all lyrics in places, marked with a special function, look like.

Cheers, Jan-Peter

--snip--
\version "2.14.2"
% create music-functions to markup lyrics
#(define-public (define-lyric-markup mup)
  (define-music-function (parser location lyrics) (ly:music?)
    (music-map
      (lambda (m)
              (begin
                (if (equal? (ly:music-property m 'name) 'LyricEvent)
                    (let ((syl (ly:music-property m 'text)))
;;; the syllable text is found in property 'lyric:text
(ly:music-set-property! m 'text (markup #:override (cons 'lyric:text syl) mup))))
                m))
      lyrics)))

% create italic lyrics
lita = \markup {
  \italic \fromproperty #'lyric:text
}
lyritalic = #(define-lyric-markup lita)

% create a wrapper for lyricsize with parameter
lyricsize = #(define-music-function (parser location size lyrics) (number? ly:music?) (let ((lsf (ly:music-function-extract (define-lyric-markup (markup #:fontsize size #:fromproperty 'lyric:text)))))
       (lsf parser location lyrics))
)

% create some other markup cmd
#(define-markup-command (hilite layout props mup)(markup?)
  "hilite markup"
(let* ((wextent (lambda (ext diff) `(,(- (car ext) diff) . ,(+ (cdr ext) diff) )))
         (gob (chain-assoc-get 'edge-round props 0.1))
         (gauge-stencil (interpret-markup layout props mup))
         (x-ext (wextent (ly:stencil-extent gauge-stencil X) gob))
         (y-ext (wextent (ly:stencil-extent gauge-stencil Y) gob))
         (color (chain-assoc-get 'hilite-color props yellow)))
        (interpret-markup layout props
(markup #:combine #:with-color color #:filled-box x-ext y-ext gob #:with-color red mup))))
% use the new markup command
lite = \markup {
  \hilite \fromproperty #'lyric:text
}
lyrhilite = #(define-lyric-markup lite)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% example
\relative c' {
  e4 a b c b bes a aes g ges f e ees d des c
} \addlyrics {
a \lyritalic { b c } d e \lyricsize #3 { f g h } i j k \lyrhilite { l m n o p }
}
--snip--




reply via email to

[Prev in Thread] Current Thread [Next in Thread]