bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tweaked X-offset returns to the value it would have had without \tweak


From: Jean Abou Samra
Subject: Tweaked X-offset returns to the value it would have had without \tweak
Date: Sun, 31 Jan 2021 13:43:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0

Hi,

Take a look at the following code:

\version "2.23.1"

#(define ((note-head-info from) note-head)
   (ly:message "From ~a: NoteHead.color = ~s   NoteHead.X-offset = ~s"
               from
               (ly:grob-property note-head 'color)
               (ly:grob-property note-head 'X-offset)))

\layout {
  \context {
    \Score
    \consists
      #(lambda (context)
         (make-engraver
           (acknowledgers
             ((note-head-interface engraver grob source-engraver)
                ((note-head-info "engraver") grob)))))
  }
  \context {
    \Voice
    \override NoteHead.stencil =
      #(note-head-info "NoteHead.stencil")
    \override NoteHead.after-line-breaking =
      #(note-head-info "NoteHead.after-line-breaking")
    \override NoteHead.before-line-breaking =
      #(note-head-info "NoteHead.before-line-breaking")
  }
}


{
  \override NoteHead.color = "red"
  \override NoteHead.X-offset = 3.14159
  c
  \tweak color "blue"
  \tweak X-offset -1
  e
}


This makes two overrides to NoteHead properties, one
to color and one to X-offset, and shows their values
at various stages of the typesetting process. The first
note takes its property from context defaults, the second
is tweaked.

The output is:


GNU LilyPond 2.23.1
Processing `tmp.ly'
Parsing...
Interpreting music...
From engraver: NoteHead.color = "red"   NoteHead.X-offset = 3.14159
From engraver: NoteHead.color = "blue"   NoteHead.X-offset = -1
Preprocessing graphical objects...
From NoteHead.before-line-breaking: NoteHead.color = "red" NoteHead.X-offset = 3.14159 From NoteHead.before-line-breaking: NoteHead.color = "blue" NoteHead.X-offset = -1
From NoteHead.stencil: NoteHead.color = "blue" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "red" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "red" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "blue" NoteHead.X-offset = 3.14159
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
From NoteHead.after-line-breaking: NoteHead.color = "red" NoteHead.X-offset = 3.14159 From NoteHead.after-line-breaking: NoteHead.color = "blue" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "blue" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "red" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "blue" NoteHead.X-offset = 3.14159
From NoteHead.stencil: NoteHead.color = "red" NoteHead.X-offset = 3.14159
Converting to `tmp.pdf'...
Success: compilation successfully completed


In the translation phase and the before-line-breaking,
callback everything looks expected. The red note has the
X-offset given in the \override, and the blue one has
X-offset specified to the \tweak.

Then things become weird. For both note heads, the X-offset
is the value given to \override, as if \tweak has not
come in. Everything works for color, however.

To clarify, it is expected that grob properties can change
in the lifetime of a grob. Callbacks have calls to
ly:grob-set-property!, ly:grob-translate-axis!
and friends (and their C++ equivalents). It is unexpected
for me, however, that the value of X-offset here is mutated
during the pure phase before page breaking (as evidenced
by log messages). Even more surprising is that it returns
to the value that was the default in the context, even
though the context object is supposed to be long dead.

Thanks,
Jean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]