.fr-emoticon.fr-emoticon-img {
                               background-repeat: no-repeat !important;
                               font-size: inherit;
                               height: 1em;
                               width: 1em;
                               min-height: 20px;
                               min-width: 20px;
                               display: inline-block;
                               margin: -0.1em 0.1em 0.1em;
                               line-height: 1;
                               vertical-align: middle;
                           }
                           .fr-emoticon {
                               font-weight: normal;
                               font-family: "Apple Color Emoji","Segoe UI Emoji","NotoColorEmoji","Segoe 
UI Symbol","Android Emoji","EmojiSymbols";
                               display: inline;
                               line-height: 0;
                           }
                       Hello Jakob,
thank you, but I would never have figured out the use of GridLine for this 
purpose on my own also ;-)
I added calculation of the x-Position, so the first notehead is centered over 
the dots of the bass clef automatically. The parameter x-off is optional 
now.You can call the music function in front of the staff definitions. In 
addition with the removal of the time-signature-engraver in the layout-block, 
everything is clearer and better readable, I think.
Juergen.
%%%%%%%%%%%%%%%%%%%%%%%%%%\version "2.24.0"

\language "deutsch"

%% based on https://www.mail-archive.com/lilypond-user@gnu.org/msg119983.html
positionTimeSignature =
#(define-music-function (x-off arg) ((number? -0.75) markup?)
  "Create a markup from @var{arg}. Center the markup vertically between 
two staves.
   Horizontally aligned to the end of the clefs; can be optionally adjusted with 
@var{x-off}."
  #{
    \once \override Score.GridLine.stencil =
    #(lambda (grob)
       (let* (
               ; create grid-line stencil for calculations
               (stil (ly:grid-line-interface::print grob))
               (stil-y-ext (ly:stencil-extent stil Y))
               (center ( / (+ (car stil-y-ext) (cdr stil-y-ext)) 2))


               ; calculate widest x-extent of clefs relative to system
               (refp (ly:grob-system grob))
               (all-elts (ly:grob-array->list (ly:grob-object refp 
'all-elements)))
               (clefs (filter (lambda (elt)
                                (grob::has-interface elt 'clef-interface))
                              all-elts))

               (max-x (apply max (map (lambda (clef)
                                        (max (+ (ly:grob-relative-coordinate 
clef refp X)
                                               (car (ly:grob-property clef 
'X-extent)))
                                          (+ (ly:grob-relative-coordinate clef 
refp X)
                                            (cdr(ly:grob-property clef 
'X-extent)))))
                                   clefs)))

               ; create time-signature markup
               (note
                (interpret-markup
                 (ly:grob-layout grob)
                 (ly:grob-alist-chain grob
                   (ly:output-def-lookup (ly:grob-layout grob) 
'text-font-defaults))
                 arg))

               ; calculate offsets for translation
               (note-y-ext (ly:stencil-extent note Y))
               (height (interval-length (ly:stencil-extent note Y)))
               (calc-y (- (- center (car note-y-ext)) ( / height 2)))
               (calc-x (+ (- max-x (ly:grob-relative-coordinate grob refp X)) 
x-off)))

         ;return translated stencil
         (ly:stencil-translate note (cons calc-x  calc-y))))
  #})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% definiton of custom time signature as markup
sig = \markup { \teeny \line { \note {2} #1 \note {4} #UP } }

\score {
 \new PianoStaff <<
   % no need to put inside voice context
   \positionTimeSignature \sig
   \new Staff <<
     \key d \major
     \new Voice {  \voiceOne d'4 \bar "|" }
     \new Voice { \voiceTwo a4 }
   >>
   \new Staff <<
     \clef bass \key d \major
     \new Voice { \voiceOne fis4 }
     \new Voice { \voiceTwo d4 }
   >>
 >>
}

\layout {
 \context {
   \Score
   \consists "Grid_line_span_engraver"
   \override GridLine.stencil = ##f

 }
 \context {
   \Staff
   \consists "Grid_point_engraver"
   %% adjust the value if needed
   gridInterval = #(ly:make-moment 1/64)
   % remove for all staves
   \remove "Time_signature_engraver"
 }
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Reply via email to