lilypond-user
[Top][All Lists]
Advanced

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

Re: Maintaining font-size regardless of staff-size


From: Thomas Morley
Subject: Re: Maintaining font-size regardless of staff-size
Date: Sat, 19 May 2018 16:02:11 +0200

2018-05-16 16:26 GMT+02:00 David Sumbler <address@hidden>:
> At the moment I define variables for formatting title, composer etc. at
> the start of a score separately for each staff-size that I use.
>
> A simple question: is there a way of getting the same layout and font-
> sizes for the opening headings of, say, a part with 20-point staves and
> a full score with 16-point staves without having to define the layout
> twice?
>
> Using \abs-fontsize does not work, because the horizontal spacing is
> still affected by the global staff size.
>
> David


Hi David,

I tried this and that and now come up with below.

Seems the results are consistent, I recommend further testings, though.
I'm not sure why it seems to work now, but I'm not a font-expert.
The text is now a (very) little taller, but I'd say it's a good trade-off
.
Looking at the output of the examples one can definetly state
abs-fontsize is buggy like hell.


#(define-markup-command (abs-fontsize-harm layout props size arg)
  (number? markup?)
  #:properties ((word-space 0.6) (baseline-skip 3))
  #:category font
  "Use @var{size} as the absolute font size (in points) to display @var{arg}.
Adjusts @code{baseline-skip} and @code{word-space} accordingly.

@lilypond[verbatim,quote]
\\markup {
  default text font size
  \\hspace #2
  \\abs-fontsize #16 { text font size 16 }
  \\hspace #2
  \\abs-fontsize #12 { text font size 12 }
}
@end lilypond"
  (let* ((ref-size (ly:output-def-lookup layout 'text-font-size 12))
         (text-props (list (ly:output-def-lookup layout 'text-font-defaults)))
         (magnification (/ size ref-size)))

    (interpret-markup
     layout
     (cons
      `((baseline-skip . ,(* magnification baseline-skip))
        (word-space . ,(* magnification word-space))
        (font-size
          .
          ,(+ (magnification->font-size magnification)
              (ly:output-def-lookup layout 'pt))))
      props)
     arg)))


\header {
  title =
    \markup
      \override #'(box-padding . 0)
      \box
      \line \box {
        \abs-fontsize-harm #10 "Absolute Font Size"
        \abs-fontsize #10 "Absolute Font Size"
      }
}

#(set-global-staff-size 26)
 \book { { b'1 } }

#(set-global-staff-size 20)
 \book { { b'1 } }

#(set-global-staff-size 10)
 \book { { b'1 } }


Cheers,
  Harm



reply via email to

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