[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Scheme: help with "Center text below hairpin dynamics"
From: |
David Stephen Grant |
Subject: |
Scheme: help with "Center text below hairpin dynamics" |
Date: |
Wed, 27 Jan 2021 21:32:07 +0100 |
Hi all,
For "Center text below hairpin dynamics" in the LSR
(http://lsr.di.unimi.it/LSR/Snippet?id=233) I'd like the text to scale
with the staff size for ossia staves. Does anyone have any pointers?
hairpinWithCenteredText =
#(define-music-function (parser location text) (markup?)
#{
\once \override Voice.Hairpin.after-line-breaking =
#(lambda (grob)
(let* ((stencil (ly:hairpin::print grob))
(par-y (ly:grob-parent grob Y))
(dir (ly:grob-property par-y 'direction))
(staff-space (ly:output-def-lookup
(ly:grob-layout grob) 'staff-space))
(staff-line-thickness
(ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
(new-stencil (ly:stencil-aligned-to
(ly:stencil-combine-at-edge
(ly:stencil-aligned-to stencil X CENTER)
Y dir
(ly:stencil-aligned-to
(grob-interpret-markup grob text) X CENTER))
X LEFT))
(par-x (ly:grob-parent grob X))
(dyn-text (grob::has-interface par-x 'dynamic-text-interface))
(dyn-text-stencil-x-length
(if dyn-text
(interval-length
(ly:stencil-extent (ly:grob-property par-x 'stencil) X))
0))
(x-shift
(if dyn-text
(-
(+ staff-space dyn-text-stencil-x-length)
(* 0.5 staff-line-thickness)) 0)))
(ly:grob-set-property! grob 'Y-offset 0)
(ly:grob-set-property! grob 'stencil
(ly:stencil-translate-axis
new-stencil
x-shift X))))
#})
hairpinPoco =
\hairpinWithCenteredText \markup { \fontsize #-1 "poco" }
music = {
\hairpinPoco
c'4 \< e' f' g' \!
}
\score {
<<
\new Staff \with {
fontSize = #-5
\override StaffSymbol.staff-space = #(magstep -5)
} \music
\new Staff \music
>>
}
- Scheme: help with "Center text below hairpin dynamics",
David Stephen Grant <=