On 2018-11-17 4:39 am, Kieren MacMillan wrote:
I really don’t understand why Lilypond’s text handling is so fussy. It
should be easy for the user to say “lines in a multi-line markup must
be exactly *this* far apart [regardless of individual glyph height]” —
in fact, it should be the default.
As far as I can see, LilyPond really does try to space lines from
baseline to baseline by the amount specified. However if a line is too
tall, the underlying composition of stencils does not permit overlap and
results in lines being further away than expected. But if you can
choose a suitably large value for baseline-skip, then the spacing really
is how you describe.
Consider this extravagantly contrived example:
%%%%
\version "2.19.82"
#(define-markup-command (show-baseline-skip layout props args) (markup?)
#:properties ((baseline-skip 0))
(let* ((stencil (interpret-markup layout props args))
(x-extent (ly:stencil-extent stencil 0))
(y-extent (ly:stencil-extent stencil 1))
(x-center (* (+ (car x-extent) (cdr x-extent)) 0.5))
(path `((moveto ,(car x-extent) 0)(lineto ,(cdr x-extent) 0)
(lineto ,x-center ,(- baseline-skip))(closepath)))
(thickness (* 0.5 (ly:output-def-lookup layout
'line-thickness))))
(interpret-markup layout props (markup #:combine args
#:with-dimensions x-extent y-extent
#:with-color (rgb-color 1 0.2 0.4)
#:path thickness path))))
#(define-markup-command (show-extents layout props args) (markup?)
(let* ((stencil (interpret-markup layout props args))
(x-extent (ly:stencil-extent stencil 0))
(y-extent (ly:stencil-extent stencil 1))
(path `((moveto ,(car x-extent) ,(car y-extent))
(lineto ,(cdr x-extent) ,(car y-extent))
(lineto ,(cdr x-extent) ,(cdr y-extent))
(lineto ,(car x-extent) ,(cdr y-extent))(closepath)))
(thickness (* 0.5 (ly:output-def-lookup layout
'line-thickness))))
(interpret-markup layout props (markup #:combine args
#:with-dimensions x-extent y-extent
#:with-color (rgb-color 0.2 0.4 1)
#:path thickness path))))
\fixed c'' {
\mark \markup \fontsize #-2 {
\center-column {
\show-extents \show-baseline-skip "qb"
\show-extents \show-baseline-skip "qb"
\show-extents \show-baseline-skip "qb"
}
\center-column {
\show-extents \show-baseline-skip "x"
\show-extents \show-baseline-skip "x"
\show-extents \show-baseline-skip "x"
}
}
\override Fingering.stencil = #(lambda (grob)
(let* ((text (ly:grob-property grob 'text))
(font-size (ly:grob-property grob 'font-size 0))
(baseline-skip (ly:grob-property grob 'baseline-skip 2))
(new-baseline-skip (* baseline-skip (magstep font-size))))
(grob-interpret-markup grob (markup #:text
#:override (cons 'baseline-skip new-baseline-skip)
#:center-column ((#:show-baseline-skip #:show-extents "^")
(#:show-baseline-skip #:show-extents text)
(#:show-baseline-skip #:show-extents text))))))
\override Fingering.font-size = #0
\override Fingering.baseline-skip = #2
g16[-\finger "q" f-\finger "x" e-\finger "b"]
\override Fingering.font-size = #3
g16[-\finger "q" f-\finger "x" e-\finger "b"]
\override Fingering.baseline-skip = #0.75
g16[-\finger "q" f-\finger "x" e-\finger "b"]
}
%%%%
The blue outlines are showing the extents of the stencils and the red
triangles are visualizing the baseline-skip. If lines are being spaced
properly, the point of a triangle will lie exactly on the baseline of
the subsequent line. Any gap between triangles indicates that the
baseline-skip was not honored.
Right away, you can see the default baseline-skip for RehearsalMarks is
too small for the font size, and so the lines with both ascenders and
descenders end up being further apart than expected because
\center-column does not want to overlap stencils.
My version of your fingering stencil function computes a idealized
baseline-skip based on the current font-size and baseline-skip. This
should be close to what you originally requested, I suspect; but be
advised that in the right-most example, I have constrained the
baseline-skip such that again we see abutting stencils where there
should be overlapping, if baseline-skip were strict.
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user