On 2018-07-08 12:54, Abraham Lee wrote:
Nothing special. Though I have dreamed of a function to do it
automatically, it just takes a bit of trial and error to find the right
size because each font has a different x-height. I almost never use an
absolute font size outside of the header. If the global staff size is
relatively small e.g. less than 16pt, then it wouldn’t hurt to make the
text size a little bit larger.
Here is a hack, which I suspect has holes that will need patching:
%%%%
\version "2.19.82"
#(define-markup-command (fontsize-x-height layout props size arg)
(number? markup?)
(let* ((y-extent (ly:stencil-extent
(ly:text-interface::interpret-markup layout
props (markup "x")) Y))
(scale-factor (* (/ size (cdr y-extent)) 1.125)))
(interpret-markup layout props #{ \markup \magnify #scale-factor
#arg #})))
\score {
<<
\new Voice { s1 }
\new Lyrics { \lyricmode {
\markup \roman \fontsize-x-height #1 "Oxy" 4
\markup \sans \fontsize-x-height #2 "Oxy" 4
\markup \typewriter \fontsize-x-height #3 "Oxy" 4
\markup \italic \fontsize-x-height #4 "Oxy" 4
} }
>>
\layout { \context { \Lyrics
% Force overlap with staff lines to use them as a ruler.
\override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
#'((basic-distance . 2) (minimum-distance . 0)
(padding . -20) (stretchability . 0))
} }
}
%%%%
The principle seems sound. Use ly:stencil-extent to measure the
height of a single "x", compute the necessary scaling factor and
\magnify.