Thank you again, David ... nice ...
one more question: The symbol list is meant for (list /interface/ /property/)? I still use (ly:grob-set-property! grob sym val) and catch interface and property with car and cadr respectivly. Or is there another way/use in 2.17?

Cheers, Jan-Peter


Am 23.07.2013 10:25, schrieb David Kastrup:
You can just have your acknowledger check for font-size being a
procedure and replace it by the result from the respective call.

And then you just use your originally failing code.  No need to invent
yet another internal interface, just make your original code work.

If you want an interface to the internals, it can look like

\allowGrobCallback font-interface.font-size

as a context mod.  Something like

allowGrobCallback =
#(define-scheme-function (parser location syms) (symbol-list?)
   #{ \with { \consists #(make-engraver ...

\version "2.17"

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

    % some "global" overrides
    \override TextScript #'font-size = \absFontSize #16
    \override LyricText #'font-size = \absFontSize #7
    \override InstrumentName #'font-size = \absFontSize #24
    \override BarNumber #'font-size = \absFontSize #18
  }
}

% example Music
\paper {
  % just to make the huge instrument name fit
  left-margin = 2\cm
}
\new Staff \with {
  instrumentName = "Melodie"
  shortInstrumentName = "Mel"
} \new Voice {
  \repeat unfold 19 \relative c'' { bes4^"Hello" a c b }
  \break
  \once \override Score.BarNumber #'font-size = \absFontSize 40
  \once \override TextScript #'font-size = \absFontSize 30
  \once \override Score.LyricText #'font-size = \absFontSize 40
  \repeat unfold 6 \relative c'' { bes4^"World" a c b
}
} \addlyrics {
  \repeat unfold 25 { B A C H } }

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

Reply via email to