Hello David,
thanks for your hint :)

Hello Kieren,
how do you like this solution?
It uses an engraver which acknowledges text-interface and font-interface (maybe we only need font-interface) and then wraps found markups in 'text and 'long-text (for InstrumentName grob) in (markup #:abs-fontsize ... /text/) It uses a property 'abs-font-size ... now lilypond complains about the unknown grob-property, but that doesn't matter for now ;)

* For instrumentName one could use different sizes for the short and the long version. * If we only need to acknowledge the font-interface, this little piece could be simplified a little bit. * We also could use the existing font-size property and use another method to "mark" it an absolute size

HTH
Cheers, Jan-Peter

On 22.07.2013 12:31, David Kastrup wrote:
The settings of font-interface and text-interface become part of the
props alist list for markup interpretation.  At the time a markup is
interpreted, no information about a possibly responsible grob is
available, so no callbacks can be executed.

\version "2.16.1"

% wrap all named properties in an abs-fontsize markup (if they are markups)
#(define (abstext grob)
   ; a new property for absolute font-size
   ; lilypond complains about the unkown property, but you can ignore that for now
   (let ((abs-font-size (ly:grob-property grob 'abs-font-size #f)))
     ; if abs-font-size is set to a positive number ...
     (if (and (number? abs-font-size)(> abs-font-size 0))
         ; ... wrap all markups found in the properties named by props
         (let ((props '(text long-text)))
           (define (wrap-text text)
             ; if text is a markup wrap it, otherwise do nothing
             (if (markup? text)
                 (let ((wtext (markup #:abs-fontsize abs-font-size text)))
                   ; we might do here more things(?)
                   wtext)
                 text))
           (for-each
            ; for all declared properties ...
            (lambda (p)
              ; re/unset 'abs-font-size, so that markups are not wrapped twice
              ; ... we are listening to font-interface and text-interface
              (ly:grob-set-property! grob 'abs-font-size #f)
              ; set property to wrapped value (if it is a markup)
              (ly:grob-set-property! grob p
                (wrap-text (ly:grob-property grob p #f)))
              ) props)
           ))))

% create an engraver with acknowledgers for text-interface and font-interface
% TODO: do we need both?
fontCheck =
#(make-engraver
  (acknowledgers
   ((text-interface engraver grob source-engraver)
    ; run abstext on any grob implementing text-interface
    (abstext grob))
   ((font-interface engraver grob source-engraver)
    ; run abstext on any grob implementing font-interface
    (abstext grob))
   ))

\layout {
  \context {
    \Score
    % "activate" acknowledgers
    \consists #fontCheck
    
    % some "global" overrides
    \override TextScript #'abs-font-size = #16
    \override LyricText #'abs-font-size = #8
    \override InstrumentName #'abs-font-size = #24
    \override BarNumber #'abs-font-size = #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 #'abs-font-size = #30
  \once \override TextScript #'abs-font-size = #30
  \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