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: David Sumbler
Subject: Re: Maintaining font-size regardless of staff-size
Date: Tue, 05 Jun 2018 17:46:42 +0100

On Thu, 2018-05-17 at 10:57 +0100, David Sumbler wrote:
> On Wed, 2018-05-16 at 16:55 +0200, David Kastrup wrote:
> > 
> > David Sumbler <address@hidden> writes:
> > 
> > > 
> > > 
> > > 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.
> > Can you show how you are using \abs-fontsize ?
> %%%%%%%%%%%%%%%%%%
> \version "2.19.81"
> 
> #(set-global-staff-size 20)
> \book {
>   \bookOutputName "test1"
>   \header { title = \markup \abs-fontsize #20 "abs-fontsize 20" }
>   { c''1 }
> }
> 
> #(set-global-staff-size 16)
> \book {
>   \bookOutputName "test2"
>   \header { title = \markup \abs-fontsize #20 "abs-fontsize 20" }
>   { c''1 }
> }
> %%%%%%%%%%%%%%%%%%
> 
> In "test2" above the title letters are the correct size, but are
> horizontally squashed together by a factor of 16/20.
> 
> David

Thank you all for the extensive discussion which followed my original
request (above).  It seems to have been established that LilyPond re-
uses previously calculated data if \abs-fontsize is called a second
time with the same font-size, even if the global staff-size has changed
in the mean time.  Unfortunately LilyPond doesn't recalculate some
items which clearly need to be recalculated.  The answer would seem to
be to make sure that \abs-fontsize either always recalculates, or at
least checks to see whether the global staff-size has changed.

It is beyond my capabilities to know how this can be done, but I hope
that in some future Lilypond version this bug will be dealt with.

Meanwhile I tweaked Torsten's version of \abs-fontsize (which made what
later was shown to be an arbitrary adjustment to the size parameter) so
that the resulting text is very slightly larger the larger the staff
size is.  That way, I thought, the difference in size is likely to be
less noticeable - although that consideration is probably irrelevant
because the adjustment is so tiny in any case.

I ended up with this:

%%%%%%%%%%%%
#(define-markup-command (abs-fontsize-DJS layout props size arg)
  (number? markup?)
  #:properties ((word-space 0.6) (baseline-skip 3))
  #:category font
  (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) (/ global-staff-size 10000))))
   (interpret-markup
    layout
    (cons
     `((baseline-skip . ,(* magnification baseline-skip))
       (word-space . ,(* magnification word-space))
       (font-size . ,(magnification->font-size magnification)))
     props)
    arg)))
%%%%%%%%%%%%

This seems to work well, so far as my usage goes so far.  The only
slight disadvantage of it is that I have to set an additional global
variable when I set the staff size, thus

%%%%%%%%%%%%
global-staff-size = 16
#(set-global-staff-size global-staff-size)
%%%%%%%%%%%%

This is because I cannot see a way of using the value of the current
staff size otherwise.  \set-global-staff-size itself does not seem to
store the value.

Obviously, though, LilyPond stores various other variables that depend
on the staff-size value, so in theory I ought to be able to use one of
those instead.  Can anyone suggest how I might do that?

David



reply via email to

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