On 2012-10-25 06:10, Keehun Nam wrote:
I know this is a novice question and I've tried what the document says to try but I don't thin its examples relate exactly to this situation although I'm sure it's been beaten into a pulp in previous discussions.I need to align "poco sf" where the sf aligns with the note head. Right now, the note head is aligned with the left of the poco.
This is actually not that straightforward to achieve, since the dynamics are centered on the notehead. If you need some text to the left of the dynamic, then the alignment point needs to be calculated explicitly. The attached file does exactly this (adapted from a LSR snippet).
Cheers, Reinhold -- ------------------------------------------------------------------ Reinhold Kainhofer, [email protected], http://www.kainhofer.com * Financial & Actuarial Math., Vienna Univ. of Technology, Austria * http://www.fam.tuwien.ac.at/, DVR: 0005886 * Edition Kainhofer, Music Publisher, http://www.edition-kainhofer.com
\version "2.17.0"
% calculate x-alignment based on attribute text + dynamic text
% this has to be a markup-command to get stencil-extent based on (interpret-markup layout props ...)
#(define-markup-command (center-dyn layout props pre-text dyn post-text)(markup? string? markup?)
"x-align on center of dynamic with pre- and post-texts"
(let* (
(pre-stencil (interpret-markup layout props (markup #:normal-text #:italic pre-text )))
(post-stencil (interpret-markup layout props (markup #:normal-text #:italic post-text)))
(dyn-stencil (interpret-markup layout props (markup #:dynamic dyn)))
(pre-x (interval-length (ly:stencil-extent pre-stencil X)))
(dyn-x (interval-length (ly:stencil-extent dyn-stencil X)))
(post-x (interval-length (ly:stencil-extent post-stencil X)))
(x-align
(* (-
(/ (+ pre-x (/ dyn-x 2)) (+ pre-x dyn-x post-x) )
0.5) 2)
)
)
(interpret-markup layout props (markup #:halign x-align #:line (#:normal-text #:italic pre-text #:dynamic dyn #:normal-text #:italic post-text)))
))
% define a 'new' attributed dynamic script
#(define (make-attr-dynamic-script pre dyn post)
(let ((dynamic (make-dynamic-script (markup #:center-dyn pre dyn post))))
(ly:music-set-property! dynamic 'tweaks (acons 'X-offset 0 (ly:music-property dynamic 'tweaks)))
dynamic))
pocosf = #(make-attr-dynamic-script "poco" "sf" "")
\relative c'' { c4\pocosf r r c\pocosf }
\relative c'' { c4\sf r r c\sf}
poco-sf.preview.pdf
Description: Adobe PDF document
_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
