lilypond-user
[Top][All Lists]
Advanced

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

Re: Flipping fingering and TextScript


From: Aaron Hill
Subject: Re: Flipping fingering and TextScript
Date: Tue, 19 Feb 2019 14:20:57 -0800
User-agent: Roundcube Webmail/1.3.8

I dug into the code a bit because I was curious why the following does not place the TextScript below the Fingering:

%%%%
    b'1 ^1 -\tweak outside-staff-priority #-1000 ^"a"
%%%%

It turns out that Fingerings have no default value for outside-staff-priority, as would be specified within define-grobs.scm. They do however have a script-priority of 100 which is lower than 200, the value for TextScripts. This means by default Fingerings should appear closer to the note in a column.

Looking at script-column.cc, the behavior appears to be to first sort all scripts in a column according to their script-priority. Once items are ordered by script-priority, they are then reordered according to outside-staff-priority. When two items share the same priority, the latter one is incremented. (script-priority is incremented by 1, and outside-staff-priority is incremented by 0.1 instead.)

When an item has no outside-staff-priority, it inherits the value of the item before it in the column. And importantly, "before" is determined by the ordering after sorting by script-priority. If there is no such item, then its value is left unset. As such, my snippet above fails because an unset priority always sorts to the beginning of the list.

One solution is to explicitly define a suitable default outside-staff-priority for Fingerings. This would prevent any unset values from skewing the sorting.

Alternately, you could opt to \tweak the outside-staff-priority of the Fingering instead, noting the default for TextScripts is 450. However, it feels a little backwards having to \tweak a different object to the one you are trying to position.

Setting the script-priority of a Fingering to a value higher than the one for TextScripts would change the default ordering of scripts in a column. Since a TextScript, which has an outside-staff-priority, appears earlier in the column, Fingerings would have a value to inherit.

Here is a snippet showing some of this behavior:

%%%%
\version "2.19.82"

#(define ((print-properties props) grob)
  (define (lookup-prop prop)
    (cons prop (ly:grob-property grob prop 'unset)))
  (let ((text (object->string (map lookup-prop props))))
    (grob-interpret-markup grob #{ \markup
      \normal-text \normalsize \tiny #text #} )))

\paper { indent = 0 ragged-right = ##t }
\layout { \context { \Voice
  \override Fingering.stencil = #(print-properties
    '(text script-priority outside-staff-priority))
  \override TextScript.stencil = #(print-properties
    '(text script-priority outside-staff-priority))
  \override TextScript.self-alignment-X = #0 } }

\markup \typewriter \bold "^1 ^2"
{ b'1 ^1 ^2 }
\markup \vspace #1
\markup \typewriter \bold "-\\tweak outside-staff-priority #100 ^1 ^2"
{ b'1 -\tweak outside-staff-priority #100 ^1 ^2 }
\markup \vspace #1
\markup \typewriter \bold "^\"a\" ^\"b\""
{ b'1 ^"a" ^"b" }
\markup \vspace #1
\markup \typewriter \bold "-\\tweak outside-staff-priority #500 ^\"a\" ^\"b\""
{ b'1 -\tweak outside-staff-priority #500 ^"a" ^"b" }
\markup \vspace #1
\markup \typewriter \bold "^1 ^\"a\""
{ b'1 ^1 ^"a" }
\markup \vspace #1
\markup \typewriter \bold "-\\tweak script-priority #300 ^1 ^\"a\""
{ b'1 -\tweak script-priority #300 ^1 ^"a" }
%%%%

-- Aaron Hill

Attachment: outside-staff-priority.cropped.png
Description: PNG image


reply via email to

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