Fragen zu TextScript.stencil

Begonnen von Hilflos-im-Code, Freitag, 4. Dezember 2020, 10:33

« vorheriges - nächstes »

Hilflos-im-Code

Ich versuche gerade mir etwas zurecht zu basteln. Das Anliegen ist, kommentierende Texte auszublenden, während musikalische Texte erhalten bleiben.

Problem 1:

\version "2.21.6"


MUS =
#(define-scheme-function
  (parser location mrkp )
  (markup? )
  #{
    \markup {

      \fontsize #-1
      \italic
      %% other syntax-possibility:
      %\override #'(font-name . ,font-name-string)

      $mrkp
    }
  #})

\score {
  \new Staff \with {
   
  }{ \override TextScript.stencil = ##f  c'_\MUS "rit."   \once \override TextScript.stencil = ##t c'_"wichtig"      c'_\MUS "rit."   c'_"wichtig"     } 
  \layout {
   \context {
      \Score
     
         
    }
 
  }

}


Trotz des "\once \override TextScript.stencil = ##t" erscheint das eine "wichtig" nicht.

Tausche ich aber t und f aus

\version "2.21.6"


MUS =
#(define-scheme-function
  (parser location mrkp )
  (markup? )
  #{
    \markup {

      \fontsize #-1
      \italic
      %% other syntax-possibility:
      %\override #'(font-name . ,font-name-string)

      $mrkp
    }
  #})

\score {
  \new Staff \with {
   
  }{ \override TextScript.stencil = ##t  c'_\MUS "rit."   \once \override TextScript.stencil = ##f c'_"wichtig"      c'_\MUS "rit."   c'_"wichtig"     } 
  \layout {
   \context {
      \Score
     
         
    }
 
  }

}

wird das einzelne "wichtig" ausgeblendet.

Was ich etwas unlogisch finde.

Anyway das Ziel ist, wenn ich ein generelles "\override TextScript.stencil = ##f" setzte, dass die Texte die ich mit \MUS einfüge weiter erscheinen.

harm6

TextScript braucht einen stencil um gedruckt zu werden. Per default ist das ly:text-interface::print.
Wenn Du \override TextScript.stencil = ##f setzt dann wird nichts gedruckt, keine Ausnahme möglich!

\override TextScript.stencil = ##t gibt einen Fehler aus, keinen stencil! Es ist also nicht der richtige Weg um einen zuvor auf #f gesetzten stencil wieder zu beleben.

Vielmehr sollt man
\temporary \override TextScript.stencil = ##f
mit
[\once]\revert TextScript.stencil
rüchgängig machen.


Gruß,
  Harm

Hilflos-im-Code

Danke.

Ich habe jetzt versucht das "\once\revert TextScript.stencil" in diese Funktion reinzuschreiben, damit alle mit MUS erzeugten Texte sichtbar bleiben. Das schaffe ich mit verschiednen Syntaxexperimenten aber nicht.
MUS =
#(define-scheme-function
  (parser location mrkp )
  (markup? )
  #{
    \markup {

      \fontsize #-1
      \italic
     
 

      $mrkp
    }
  #})

harm6

Schau doch mal, ob Du mit dem Code unten zurecht kommst.

Er basiert auf zwei miteinander interagierenden Setzungen.
(1) "print-comments" kann in \paper oder \layout auf true oder false gesetzt werden
(2) In MUS wird das property 'print-me auf true oder false gesetzt (default ist #f)

Wenn "print-comments" true ist, dann wird immer gedruckt.
Wenn "print-comments" false ist, dann wird nichts gedruckt, es sei denn extra angestossen.


\version "2.21.6"

#(define-markup-command (comment layout props arg)(markup?)
  #:properties ((print-me #f))
  (let ((print-comments? (ly:output-def-lookup layout 'print-comments #f)))
    ;; If `print-comments` from \layout or \paper is #t, a processed arg-stencil
    ;; is returned, even if `print-me` is #f
    ;; If `print-comments` is #f the value of `print-me` takes over, deciding
    ;; whether the arg-stencil or an empty-stencil is returned.
    (if (or print-comments? print-me)
        (interpret-markup layout props arg)
        empty-stencil)))

MUS =
#(define-scheme-function
  (parser location print? mrkp)
  ((boolean? #f) markup?)
  #{
    \markup {
      \override #`(print-me . ,print?)
      \comment
      \fontsize #-1
      \italic
      %% other syntax-possibility:
      %\override #'(font-name . ,font-name-string)

      $mrkp
    }
  #})
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\bookpart {
  \paper { print-comments = ##t }
 
  %% print-comments is #t at book(part) toplevel
  %% i.e. the print-me markup-property is ruled out, all comments are always
  %% visible
  \score {
    \new Staff {
      \textLengthOn
      c'2_\MUS "comment" c'_"always" c'2_\MUS ##f "comment enabled" c'_"always"
    }
  }
 
  %% print-comments is #f in score-layout, taking precedence of book(part)
  %% toplevel setting
  %% i.e. comments only visible if enabled
  \score {
    \new Staff {
      \textLengthOn
      c'2_\MUS "comment" c'_"always" c'2_\MUS ##t "comment enabled" c'_"always"
    }
    \layout {
      print-comments = ##f
    }
  }
}

\bookpart {
  \paper { print-comments = ##f }
 
  %% print-comments is #f at toplevel
  %% i.e. comments only visible if enabled
  \score {
    \new Staff {
      \textLengthOn
      c'2_\MUS "comment" c'_"always" c'2_\MUS ##t "comment enabled" c'_"always"
    }
  }
 
  %% print-comments is #t in score-layout, taking precedence of toplevel
  %% book(part) setting
  %% i.e. the print-me markup-property is ruled out, all comments are always
  %% visible
  \score {
    \new Staff {
      \textLengthOn
      c'2_\MUS "comment" c'_"always" c'2_\MUS ##f "comment enabled" c'_"always"
    }
    \layout {
      print-comments = ##t
    }
  }
}


HTH,
  Harm

Hilflos-im-Code

Danke. Ich muss mal genauer Hinschauen, weil momentan sieht es so aus, als würde es genau das Gegenteil machen, von dem was ich will.

Mit \MUS schreibe ich so etwas wie rit. oder dolce. Die sollen erhalten bleiben. Das "normale " Markup soll verschwinden.

Ich werde dann mal mir etwas mit regulären Ausdrücken einfallen lassen, dann geht das mit dem temporary. Denn das Unpraktische ist, dass [\once]\revert TextScript.stencil vor dem Ton stehen muss und nicht zwischen Ton und \MUS.