lilypond-user
[Top][All Lists]
Advanced

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

Re: _ underscore lyric hyphen


From: Thomas Morley
Subject: Re: _ underscore lyric hyphen
Date: Fri, 2 Nov 2012 22:21:55 +0100

2012/11/1 Rustik <address@hidden>:
[...]
> It works! Thank you!
>
> And now i have a new question. Can i make all as well as you tell me, but
> lyric text must be maked by "font A", for example, Times, and
> "strangeLyricHyphen" must be maked by "font B", for example Arial?
> Is it possible?

Hi,

I've rewritten the code, using more LilyPond-Syntax.

It should now be no problem to format the underscore-markup as you want.
(Currently I set `underscore´ to use '(font-name . "Cmex10"), this
will return some strange output, if you've installed "Cmex10" :)
Choose the font you prefer.)

LyricText is formated in \layout.


\version "2.16.0"

\paper {
        ragged-right = ##f
}

strangeLyricHyphens =
\override LyricHyphen #'after-line-breaking =
  #(lambda (grob)
    (let* ((l-bd (ly:grob-property grob 'left-bound-info))
           (bound-left (ly:spanner-bound grob LEFT))
           (bound-right (ly:spanner-bound grob RIGHT))
           (text-left (ly:grob-property bound-left 'text))
           (text-right (ly:grob-property bound-right 'text))
           (orig (ly:grob-original grob))
           (siblings (if (ly:grob? orig)
                 (ly:spanner-broken-into orig)
                 '() ))
;; Underscore-markup:
           (underscore #{
                   \markup \override #'(font-name . "Cmex10") "_"
                       #})

           (text-left-mrkp  #{ \markup #text-left  #})
           (text-right-mrkp #{ \markup #text-right  #})
           (new-text (grob-interpret-markup bound-left #{
                   \markup \concat { #text-left-mrkp #underscore }
                       #}))
           (add (* -1 (interval-length
                        (ly:stencil-extent
                           (grob-interpret-markup bound-left underscore)
                              X))))
           (fake-hyphen
             (ly:stencil-translate-axis
               (grob-interpret-markup bound-right
                 #{ \markup \concat { #underscore #text-right-mrkp } #})
                   add
                   X)))

    (ly:grob-set-property! grob 'transparent #t)
    (if (not (null? text-left))
      (ly:grob-set-property! bound-left 'stencil new-text)
      text-left)
    (if (and (>= (length siblings) 2)
      (eq? (car (last-pair siblings)) grob))
      (ly:grob-set-property! bound-right 'stencil fake-hyphen))))


lyr = \lyricmode {
        Cy -- ri -- e e -- lei -- son,
        Cy -- rie e -- lei -- son.
}
<<
\new Voice = "mel" \relative c' {
        c d c d c d c2 \break
        d4 c d c
}
\new Lyrics \lyricsto "mel" \lyr
>>

\new Lyrics \lyr

\layout {
  \context {
    \Lyrics
    \strangeLyricHyphens
    \override LyricText #'font-name = #"Purisa"
  }
}



HTH,
  Harm



reply via email to

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