lilypond-user
[Top][All Lists]
Advanced

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

Re: Absolute font-size for TextScript


From: Paolo Prete
Subject: Re: Absolute font-size for TextScript
Date: Tue, 2 Jun 2020 23:00:29 +0200



On Tue, Jun 2, 2020 at 8:57 PM Kieren MacMillan <kieren_macmillan@sympatico.ca> wrote:
Hi Paolo,

> is it possible to set an absolute font-size for *all* the TextScript objects?

I use this (from an include file):

%%%%
allowGrobCallback =
#(define-scheme-function (parser location syms) (symbol-list?)
   (let ((interface (car syms))
         (sym (cadr syms)))
     #{
       \with {
         \consists #(lambda (context)
                      `((acknowledgers .
                          ((,interface . ,(lambda (engraver grob source-engraver)
                                            (let ((prop (ly:grob-property grob sym)))
                                              (if (procedure? prop) (ly:grob-set-property! grob sym (prop grob)))
                                              ))))
                          ))
                      )
       }
     #}))

absFontSize =
#(define-scheme-function (parser location pt)(number?)
   (lambda (grob)
     (let* ((layout (ly:grob-layout grob))
            (ref-size (ly:output-def-lookup (ly:grob-layout grob) 'text-font-size 12)))
       (magnification->font-size (/ pt ref-size))
       )))

\layout {
  \context {
    \Score
    \allowGrobCallback font-interface.font-size
  }
}
%%%%


Thanks!!

But how exactly do I have to call \absFontSize ? I tried in the following way, but could not obtain the wanted result:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

allowGrobCallback =
#(define-scheme-function (parser location syms) (symbol-list?)
   (let ((interface (car syms))
         (sym (cadr syms)))
     #{
       \with {
         \consists #(lambda (context)
                      `((acknowledgers .
                          ((,interface . ,(lambda (engraver grob source-engraver)
                                            (let ((prop (ly:grob-property grob sym)))
                                              (if (procedure? prop) (ly:grob-set-property! grob sym (prop grob)))
                                              ))))
                          ))
                      )
       }
     #}))

absFontSize =
#(define-scheme-function (parser location pt)(number?)
   (lambda (grob)
     (let* ((layout (ly:grob-layout grob))
            (ref-size (ly:output-def-lookup (ly:grob-layout grob) 'text-font-size 12)))
       (magnification->font-size (/ pt ref-size))
       )))

% LilyBin
\score{
{
  \absFontSize 16
  c'^"foobar"
}

\layout {
  \context {
    \Score
    \allowGrobCallback font-interface.font-size
  }
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
Best,
P

reply via email to

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