On Thu, Feb 6, 2020 at 2:41 AM Aaron Hill <lilyp...@hillvisions.com> wrote:

> %%%%
> \version "2.19.83"
>
> #(define-markup-command
>    (staff-fontsize layout props size arg)
>    (number? markup?)
>    (let* ((staff-space (ly:output-def-lookup layout 'staff-space 1))
>           (sten (interpret-markup layout props (markup "x")))
>           (yex (ly:stencil-extent sten Y))
>           (height (interval-length yex))
>           (magnification (* size (/ staff-space height)))
>           (font-size (magnification->font-size magnification)))
>      (interpret-markup layout props
>        (markup (#:fontsize font-size arg)))))
>
> test =
> \new Staff
>    \with {
>      \omit Clef
>      \omit TimeSignature
>      \override NoteHead.stencil =
>        #(lambda (grob)
>          (grob-interpret-markup grob #{
>            \markup {
>              \staff-fontsize #1 "bxq"
>              \staff-fontsize #2 "bxq"
>              \staff-fontsize #3 "bxq"
>              \staff-fontsize #4 "bxq"
>            } #}))
>    }
>    { e'1 }
>
> \score { \test \layout { #(layout-set-staff-size 12) } }
> \score { \test \layout { #(layout-set-staff-size 20) } }
> \score { \test \layout { #(layout-set-staff-size 28) } }
> %%%%
>
> 'x' usually has a flat top and bottom, making it a stable reference.  If
> the x-height is not your interest, you can substitute 'x' for something
> else.  Just be aware that some glyphs often have larger physical
> dimensions than their ideal bounds as a way to compensate for optic
> effects.  This is most noticeable with rounded or pointed features.  If
> you wanted to measure 'o', for instance, you would need to adjust the
> height computation:
>
> %%%%
>           (height (+ (interval-length yex) (* 2 (car yex))))
> %%%%
>
> The principle here is to assume that the extent with which the character
> descends is the optic adjustment, so we subtract it from the top and
> bottom to get the effective height.  This only works with glyphs that
> are vertically symmetric in this regard.  An 'A', for instance, usually
> has a flat bottom but the point at the top often extends slightly beyond
> its nominal height.
>
>
> -- Aaron Hill
>
>

Thank you very much, Aaron

Reply via email to