• Willkommen im Forum „Archiviertes Lilypond Forum (2017)“.
 

Dies ist das Archiv des alten Forums (bis März 2017). Das aktuelle Forum ist unter lilypondforum.de zu finden.
This is the archive of the old forum (until March 2017). You can find the current forum at lilypondforum.de.

Hauptmenü

Markup Kommando für eigene Titelformatierung erstellen (selbst gelöst)

Begonnen von Manuela, Donnerstag, 28. Juli 2016, 13:28

Vorheriges Thema - Nächstes Thema

Manuela

Hallo,

ich scheitere wieder einmal an den einfachsten Dingen. Ich will einen Text verfassen (ich weiß, Lilypond ist nicht das optimale Tool für Textverarbeitung), und Zwischentitel erstellen. Die Formatierung will ich nur an einer Stelle ändern müssen

version "2.19.37"

#(define-markup-list-command (paragraph layout props args) (markup-list?)
   #:properties ((par-indent 2))
   (interpret-markup-list layout props
     #{\markuplist \justified-lines { \hspace #par-indent #args } #}))

\book {
  \markuplist {
    \vspace #1
    \line {
      \scale #'(1.1 . 1) \fontsize #2 \sans \underline  "Titel 1"
      %\titel-one Rhythmus
    }

    \vspace #1
    \paragraph {
      Text 1. Paragraph
    }
    \vspace #1
    \line {
      \scale #'(1.1 . 1) \fontsize #2 \sans \underline  "Titel 2"
      %\titel-one Rhythmus
    }

    \vspace #1
    \paragraph {
      Text 2. Paragraph
    }
  }
}

%% so funktioniert es klarerweise nicht:
%Meintitel= { \scale #'(1.1 . 1) \fontsize #2 \sans \underline }
%%....
%%\line { \Meintitel "Titel 1"  }
%% ...
%%\line { \Meintitel "Titel 2" }



Ich habe auch probiert, eine Scheme-Funktion nach diesem Muster zu schreiben, bin jedoch gescheitert:

(define-markup-command (Meintitel layout props factor-pair arg)
  (number-pair? markup?)
  #:category graphic
    (let ((stil (interpret-markup layout props arg))
        (sx (car factor-pair))
        (sy (cdr factor-pair)))
    (ly:stencil-scale stil sx sy)))



harm6

Hallo Manuela,

ich verstehe nicht was Dir vorschwebt.

ZitatDie Formatierung will ich nur an einer Stelle ändern müssen

Was genau soll wie formatiert werden?

ZitatIch habe auch probiert, eine Scheme-Funktion nach diesem Muster zu schreiben

Es handelt sich doch eher um ein markup-command, denn um eine scheme-function. Aber wo und wie solls angewendet werden?


Gruß,
  Harm

Manuela

#2
Ausgehend von http://lilypond.org/doc/v2.19/Documentation/changes/ dachte ich, ich hätte die Lösung für mein Problem gefunden. Leider funktioniert es nur außerhalb von markuplist  :(

\version "2.19.37"

bold-red-markup = \markup \bold \with-color #red \etc

#(define-markup-list-command (paragraph layout props args) (markup-list?)
   #:properties ((par-indent 2))
   (interpret-markup-list layout props
     #{\markuplist \justified-lines { \hspace #par-indent #args } #}))

\markuplist {
  \vspace #1
  \line {
    \bold \with-color #red "Titel 1"
  }
  \vspace #1
  \line {
    \bold-red-markup "Titel 1 in line" %% liefert einen Fehler
  }
  \vspace #1
  \bold-red-markup "Titel 1 außerhalb von line" %% liefert einen Fehler
  \vspace #1
  \paragraph {
    \line { Text 1. Paragraph }
  }
}
\markup \bold-red "text"  %% das funktioniert

Manuela

Meine Frage war irreführend formuliert. Was ich tatsächlich gemeint habe, war eine Zusammenfassung mehrerer Markup-Kommandos wie \underline, \scale, \fontsize ... zu einem einzigen Kommando.

In der Zwischenzeit habe ich eine Menge über Scheme und Markup gelernt und war dadurch imstande, das Problem durch Studium der Datei define-markup-commands.scm selbst zu lösen, falls es jemanden interessiert:

\version "2.19.37"

#(define-markup-command (my-header layout props arg)
   (markup?)
   #:properties ((thickness 1) (offset 2)
                  (font-size 0)
                  (word-space 1)
                  (baseline-skip 2))
   (let* ((thick (ly:output-def-lookup layout 'line-thickness))
          (underline-thick (* thickness thick ))
          (increment 2)
          (m (interpret-markup layout
               (prepend-alist-chain 'font-family 'sans
                 (cons
                  `((baseline-skip . ,(* baseline-skip (magstep increment)))
                    (word-space . ,(* word-space (magstep increment)))
                    (font-size . ,(+ font-size increment)))
                  props))
               arg))
          (m2 (ly:stencil-scale m 1.1 1))
          (x1 (car (ly:stencil-extent m2 X)))
          (x2 (cdr (ly:stencil-extent m2 X)))
          (y (* thick (- offset) (magstep increment)))
          (line (make-line-stencil underline-thick x1 y x2 y)))
     (ly:stencil-add m2 line)))

\markup \my-header { "dieser Text wird leicht gesperrt, unterstrichen, sans und vergrößert" }

\markup \my-header { setzt man keine Anführungszeichen, wird jedes Wort einzeln unterstrichen }