On 2020-01-24 9:12 am, Paolo Prete wrote:
I'm trying to implement the work-around you suggested.
TupletNumber doesn't cause the discussed weird space.
However, this weird space happens as soon as I access the stencil (or
any
property of it) of the TupletBracket grob
Then, even if I get the bracket's grob with (ly:grob-object number-grob
'bracket), I can't access its stencil, nor its y-extent through
this variable. Is this what you were suggesting or do I have to follow
another method?
Alas, my workaround required that you did not need to touch
TupletBracket's stencil property at all. Rather, switching to
TupletNumber might have provided you a grob that would host the
visualization more reliably. But if you need to access TupletBracket's
stencil from after-line-breaking, there is no getting around the issue.
In digging more deeply, the unexpected added space looks to come from
accessing the TupletBracket's positions property; and since stencil
depends on positions internally, querying the stencil triggers the
behavior. This property is concerned with the vertical placement of the
ends of the bracket, and its computation involves checking a number of
associated grobs (e.g. NoteColumns and Beams). By querying positions
too early in the layout process, this seems to unintentionally lock in
bad values resulting in improper spacing. And unfortunately,
TupletBracket's after-line-breaking procedure gets invoked *before* its
positions property would normally be queried, so my visualization hack
interferes with the usual timing of things.
Since TupletBracket's stencil appears to be consulted fairly late in the
game, you probably do not need to bother with after-line-breaking at
all. Instead, simply replace the normal stencil procedure
(ly:tuplet-bracket::print) with a custom one, overlaying whatever you
need. In 2.19, there is grob-transformer, which makes this easy:
%%%%
\version "2.19.83"
\paper {
#(set-paper-size "a9landscape")
top-margin = 0.75\cm line-width = 3.5\cm
indent = 0 ragged-right = ##f tagline = ##f
}
visualize-stencil-extent-and-origin = #(define-music-function
(grob-path) (symbol-list?)
(define proc (grob-transformer 'stencil
(lambda (grob orig)
(let* ((xex (ly:stencil-extent orig X))
(yex (ly:stencil-extent orig Y)))
(ly:grob-set-property! grob 'layer 1000)
(grob-interpret-markup grob #{
\markup
\with-dimensions-from \stencil #orig
\overlay {
\with-color #'(0.2 0.7 0.9)
\override #'(style . outline)
\override #`(thickness . 1.2)
\whiteout
\path #0.1 #`(
(moveto ,(- (car xex) 1.5) ,(car yex))
(lineto ,(+ (cdr xex) 1.5) ,(car yex))
(moveto ,(- (car xex) 1.5) ,(cdr yex))
(lineto ,(+ (cdr xex) 1.5) ,(cdr yex))
(moveto ,(car xex) ,(- (car yex) 1.5))
(lineto ,(car xex) ,(+ (cdr yex) 1.5))
(moveto ,(cdr xex) ,(- (car yex) 1.5))
(lineto ,(cdr xex) ,(+ (cdr yex) 1.5)))
\with-color #'(0.9 0.4 0.2)
\override #'(style . outline)
\override #`(thickness . 0.9)
\whiteout
\path #0.1 #`(
(moveto -1.5 -1.5) (lineto 1.5 1.5)
(moveto -1.5 1.5) (lineto 1.5 -1.5))
\override #'(style . outline)
\override #`(thickness . 0.6)
\whiteout
\stencil #orig
} #} )))))
#{ \override $grob-path .stencil = #proc #})
\fixed c' {
\visualize-stencil-extent-and-origin TupletBracket
\tuplet 3/2 { c2 f8 bes }
}
%%%%
-- Aaron Hill