lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opinions: expressive text and markup sizes


From: Urs Liska
Subject: Re: Opinions: expressive text and markup sizes
Date: Mon, 9 Jul 2018 07:49:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0



Am 09.07.2018 um 00:11 schrieb Aaron Hill:
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.

That looks interesting and could also lead to something like (LaTeX) fontspec's ability to match the size of various fonts by their x-height (Scale=MatchLowercase or so).

However, there is something odd with the units returned.  I experimentally found that a fudge factor of 1.125 appeared to mostly correct things, but I am almost certainly just overlooking something important.

I would try to draw a rectangle with the determined extent and then try with different fonts. Maybe that gives you some indication where the issue might lie. Maybe it's with LilyPond's typesetting, but maybe it's built into the font metrics?

Best
Urs


-- Aaron Hill

_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

[Prev in Thread] Current Thread [Next in Thread]