Hi Jan-Peter, 2010/12/13 Jan-Peter Voigt <jp.vo...@gmx.de>
> Hello list, > > I wrote a script to align dynamics centered on the corresponding note: > > --snip-- > \version "2.12.3" > > % calculate x-alignment based on attribute text + dynamic text > #(define-markup-command (center-dyn layout props atr-text dyn)(markup? > string?) > "x-align on center of dynamic" > (let* ( > (text (string-append atr-text " ")) > (atr-stencil (interpret-markup layout props (markup #:normal-text > #:italic text))) > (dyn-stencil (interpret-markup layout props (markup #:dynamic > dyn))) > (atr-x-ext (ly:stencil-extent atr-stencil X)) > (dyn-x-ext (ly:stencil-extent dyn-stencil X)) > (atr-x (- (cdr atr-x-ext)(car atr-x-ext))) > (dyn-x (- (cdr dyn-x-ext)(car dyn-x-ext))) > (x-align > (* (- > (/ (+ atr-x (/ dyn-x 2)) (+ atr-x dyn-x) ) > 0.5) 2) > ) > ) > (interpret-markup layout props (markup #:halign x-align #:concat > (#:normal-text #:italic text #:dynamic dyn))) > )) > > % define some dynamics > pocof = #(make-dynamic-script (markup #:center-dyn "poco" "f")) > menof = #(make-dynamic-script (markup #:center-dyn "meno" "f")) > subp = #(make-dynamic-script (markup #:center-dyn "subito" "p")) > > % activate X-offset, so that halign works > dynx = #(define-music-function (parser location musik)(ly:music?) > #{ > \override DynamicText #'X-offset = #0 $musik \revert DynamicText > #'X-offset > #}) > > %%%%% example %%%%% > << > \new Staff << > \relative c'' { > d \dynx c\pocof d e | d\ff d cis eis ~ | \dynx eis1\subp | r4 \dynx > b\menof c\f > } > >> > >> > --snip-- > > This script first calculates the widthes of the "attribute"-text (wa) and > the dynamic text (wd), so that I can calculate the right \halign value: > halign = ((wa + (wd / 2)) / (wa + wd) - 0.5) * 2 > > Then I use a markup with \halign. This works quite well as long DynamicText > #'X-offset is set! If that is set all other dynamics are aligned badly. > So I wrote a little function, that sets and unsets (reverts) that value to > let the halign work. > > My question is: > Is it possible to set that value inside the make-dynamic-script or align it > some other way, so that I can simply use my defined \pocof (etc.) without > switching X-offset on and off? > > Regards, > Jan-Peter > I can not answer your question, but it is probably better placed on lilypond-devel (cc-ing). Marek
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel