Hi lilypond users,
I have a question about getting the Y position of a grob. I saw this
question has been asked previously but I could not find if it had been
answered. In the following example, an after-line-breaking function is
defined such that no change on the output should occur. The grob is only
queried with (ly:grob-extent grob ... Y) but this value is not used. There
is a difference in the vertical spacing between the staves of the staff
group based on whether this query is present or not. The intention is to be
able to query a grob for its Y position relative to another grob in order
to draw cross-staff spanners, where it is necessary to calculate the
distance between grobs not only on the X axis but also on the Y axis. Here,
the system is being used to accurately get the X position, but using the
system to get the Y position triggers this spacing error but appears to
return the correct position before the spacing shift.

%%%%%%% START EXAMPLE %%%%%%%
\language "english"
\version "2.23.14"

#(set-global-staff-size 12)

\score {
    <<
        \new Staff {
            \once \override NoteHead.after-line-breaking = #(lambda (grob)
                    (let*
                        (
                           (sys (ly:grob-system grob))
                           (x-extent (ly:grob-extent grob sys X))
                           ;;uncomment y-extent to cause spacing error
                           ;(y-extent (ly:grob-extent grob sys Y))
                        )
                        (display (list x-extent ))
                    )
                )
            c'1
            c'1
            c'1
            c'1
        }
        \new Staff {
            c'1
            c'1
            c'1
            c'1
        }
    >>
}

%%%%%%% END EXAMPLE %%%%%%%


best,
-- 
gregory rowland evans
http://www.gregoryrowlandevans.com
https://github.com/GregoryREvans
https://soundcloud.com/gregory-rowland-evans

Reply via email to