fix horizontal positions of tuplet brackets
Currently, the callback for TupletBracket.X-positions
produces horizontal positions that don't conform to standard typesetting practice. Paul Hodges writes:
Both Ross (p161) and Gould (p195) are completely clear when they say that the left hand end of a tuplet bracket aligns with the left-hand side of the first note.
The follow-up discussion cumulated in a patch from Harm; which is shown here (with slight extensions).
\version "2.23.9"
#(define tuplet-bracket::wrap-all-note-heads
(grob-transformer 'X-positions
(lambda (grob orig)
;; `orig' is the result of `ly:tuplet-bracket::calc-x-positions'
;; we calculate some left/right corrections adding them to it.
;; Because `orig' places TupletBracket ends not really centered above
;; the stems we need to take TupletBracket and Stem thickness into account
(let* ((thick (ly:grob-property grob 'thickness))
(line-thick (ly:staff-symbol-line-thickness grob))
(used-thick (* thick line-thick))
(right-bound (ly:spanner-bound grob RIGHT))
(left-bound (ly:spanner-bound grob LEFT))
;; Don't change `orig' if left or right bound is not NoteColumn
(add-left
(if (grob::has-interface left-bound 'note-column-interface)
(+ (/ used-thick 2)
(let* ((left-stem (ly:grob-object left-bound 'stem))
(lst-dir (ly:grob-property left-stem 'direction))
(lst-th (ly:grob-property left-stem 'thickness))
(lst-coord
(ly:grob-relative-coordinate
left-stem
left-bound
X))
(lb-X-ext
(ly:grob-property left-bound 'X-extent)))
(if (positive? lst-dir)
(- lst-coord)
(- (car lb-X-ext) (/ (* lst-th line-thick) 2)))))
0))
(add-right
(if (grob::has-interface right-bound 'note-column-interface)
(let* ((rb-X-ext (ly:grob-property right-bound 'X-extent))
(right-stem (ly:grob-object right-bound 'stem))
(rst-coord
(ly:grob-relative-coordinate
right-stem
right-bound
X)))
(+ (- rst-coord)
(/ used-thick -2)
(cdr rb-X-ext)))
0)))
(cons (+ (car orig) add-left) (+ (cdr orig) add-right))))))
\paper {
line-width = 6\cm
}
music = {
%% To get all broken parts visible:
\override TupletBracket.bracket-visibility = ##t
\voiceOne
\times 2/3 { <c>4 q q }
\voiceTwo
\times 2/3 { <c> q \bar "" \break q }
\voiceOne
\times 2/3 { <c d> q \bar "" \break q }
\voiceTwo
\times 2/3 { <c d> \bar "" \break q q }
}
\relative c'' {
\mark \markup \normalsize "without correction"
\music
}
\relative c'' {
\override TupletBracket.X-positions = #tuplet-bracket::wrap-all-note-heads
\mark \markup \normalsize "with correction"
\music
}
A fix should incorporate these Scheme changes directly into Tuplet_Bracket::calc_position_and_height
in file tuplet-bracket.cc
.