Modifying Stencil for Clef

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Modifying Stencil for Clef

Richard Shann-2
I've been following up the idea of using markup as stencils:

http://lilypond.org/doc/v2.18/Documentation/notation/modifying-stencils

and have got it working for NoteHead and for Dots (which was my use-
case). But trying to generalize to more layout objects I ran into
trouble. This I expected would replace the change of clef with a "T"
but it does not:

\version "2.18.2"
{
  c'
  \once \override ClefModifier.stencil = #ly:text-interface::print
  \once \override ClefModifier.text = \markup{T}
  \clef bass
  c'
}

Any ideas?

Richard


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Richard Shann-2
On Fri, 2019-02-22 at 11:49 +0000, Richard Shann wrote:

> I've been following up the idea of using markup as stencils:
>
> http://lilypond.org/doc/v2.18/Documentation/notation/modifying-stenci
> ls
>
> and have got it working for NoteHead and for Dots (which was my use-
> case). But trying to generalize to more layout objects I ran into
> trouble. This I expected would replace the change of clef with a "T"
> but it does not:
>
> \version "2.18.2"
> { 
>   c'
>   \once \override ClefModifier
                    ^^^^^^^^^^^^

Sorry, this was my second attempt, my first used the Clef layout
object. But the result it the same

\version "2.18.2"
{
  c'
  \once \override Clef.stencil = #ly:text-interface::print
  \once \override Clef.text = \markup{T}
  \clef bass
  c'
}

Richard


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Andrew Bernard
In reply to this post by Richard Shann-2
Hi Richard,
This came up in relation to something I was doing only a week or so ago. Have a look here:


Andrew


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Lukas-Fabian Moser
In reply to this post by Richard Shann-2

Am 22.02.19 um 12:49 schrieb Richard Shann:

> I've been following up the idea of using markup as stencils:
>
> http://lilypond.org/doc/v2.18/Documentation/notation/modifying-stencils
>
> and have got it working for NoteHead and for Dots (which was my use-
> case). But trying to generalize to more layout objects I ran into
> trouble. This I expected would replace the change of clef with a "T"
> but it does not:
>
> \version "2.18.2"
> {
>    c'
>    \once \override ClefModifier.stencil = #ly:text-interface::print
>    \once \override ClefModifier.text = \markup{T}
>    \clef bass
>    c'
> }
>
> Any ideas?

Clef modifiers are the numbers indicating transposition (ottava violin
clef etc.).

Try:

\version "2.18.2"
{
   c'
   \once \override Staff.Clef.stencil = #ly:text-interface::print
   \once \override Staff.Clef.text = \markup{T}
   \clef bass
   c'
}

Lukas


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Richard Shann-2
In reply to this post by Andrew Bernard
On Fri, 2019-02-22 at 23:00 +1100, Andrew Bernard wrote:
> Hi Richard,
> This came up in relation to something I was doing only a week or so
> ago. Have a look here:
>
> https://lists.gnu.org/archive/html/lilypond-user/2019-02/msg00297.htm
Thank you!
It seems I have to prefix the layout object Clef with Staff. So

\version "2.18.2"
{
  c'
  \once \override Staff.Clef.stencil = #ly:text-interface::print
  \once \override Staff.Clef.text = \markup{T}
  \clef bass
  c'
}

works as expected. As I'm trying to make a general tool here, could
someone explain why this is needed - I see I can prefix Dots with Staff
and Staff.Accidental is ok too, though not needed.

Richard


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Richard Shann-2
In reply to this post by Lukas-Fabian Moser
On Fri, 2019-02-22 at 13:04 +0100, Lukas-Fabian Moser wrote:

> Am 22.02.19 um 12:49 schrieb Richard Shann:
> > I've been following up the idea of using markup as stencils:
> >
> > http://lilypond.org/doc/v2.18/Documentation/notation/modifying-sten
> > cils
> >
> > and have got it working for NoteHead and for Dots (which was my
> > use-
> > case). But trying to generalize to more layout objects I ran into
> > trouble. This I expected would replace the change of clef with a
> > "T"
> > but it does not:
> >
> > \version "2.18.2"
> > {
> >    c'
> >    \once \override ClefModifier.stencil = #ly:text-interface::print
> >    \once \override ClefModifier.text = \markup{T}
> >    \clef bass
> >    c'
> > }
> >
> > Any ideas?
>
> Clef modifiers are the numbers indicating transposition (ottava
> violin 
> clef etc.).

Thanks - I see - ClefModifier is then an interesting case, I can
imagine people wanting to tweak the modifier, but that fails for me
even with the specifier "Staff." inserted:

\version "2.18.2"
{
  c'
 \override Staff.ClefModifier.stencil = #ly:text-interface::print
 \once \override Staff.ClefModifier.text = \markup{T}
 \clef "bass_8"
  c'
}

Just shows the italic 8 as usual.

Richard


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
dak
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

dak
In reply to this post by Richard Shann-2
Richard Shann <[hidden email]> writes:

> On Fri, 2019-02-22 at 23:00 +1100, Andrew Bernard wrote:
>> Hi Richard,
>> This came up in relation to something I was doing only a week or so
>> ago. Have a look here:
>>
>> https://lists.gnu.org/archive/html/lilypond-user/2019-02/msg00297.htm
> Thank you!
> It seems I have to prefix the layout object Clef with Staff. So
>
> \version "2.18.2"
> {
>   c'
>   \once \override Staff.Clef.stencil = #ly:text-interface::print
>   \once \override Staff.Clef.text = \markup{T}
>   \clef bass
>   c'
> }
>
> works as expected. As I'm trying to make a general tool here, could
> someone explain why this is needed - I see I can prefix Dots with Staff
> and Staff.Accidental is ok too, though not needed.

The default override is done at Bottom level (which typically resolves
to Voice).  Overrides change the defaults for grobs created by engravers
in the given contexts and all subordinate contexts.

Grobs like noteheads are created by engravers in Voice contexts, so you
can override in a given Voice, or at Staff level (assuming that no
override at Voice level takes priority).  Grobs like Clef and
TimeSignature however are created by engravers in Staff contexts which
don't consult the defaults for Voice contexts.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Richard Shann-2
On Fri, 2019-02-22 at 13:35 +0100, David Kastrup wrote:

> Richard Shann <[hidden email]> writes:
>
> > On Fri, 2019-02-22 at 23:00 +1100, Andrew Bernard wrote:
> > > Hi Richard,
> > > This came up in relation to something I was doing only a week or
> > > so
> > > ago. Have a look here:
> > >
> > > https://lists.gnu.org/archive/html/lilypond-user/2019-02/msg00297
> > > .htm
> >
> > Thank you!
> > It seems I have to prefix the layout object Clef with Staff. So 
> >
> > \version "2.18.2"
> > { 
> >   c'
> >   \once \override Staff.Clef.stencil = #ly:text-interface::print 
> >   \once \override Staff.Clef.text = \markup{T}
> >   \clef bass 
> >   c'
> > }
> >
> > works as expected. As I'm trying to make a general tool here, could
> > someone explain why this is needed - I see I can prefix Dots with
> > Staff
> > and Staff.Accidental is ok too, though not needed.
>
> The default override is done at Bottom level (which typically
> resolves
> to Voice).  Overrides change the defaults for grobs created by
> engravers
> in the given contexts and all subordinate contexts.
>
> Grobs like noteheads are created by engravers in Voice contexts, so
> you
> can override in a given Voice, or at Staff level (assuming that no
> override at Voice level takes priority).  Grobs like Clef and
> TimeSignature however are created by engravers in Staff contexts
> which
> don't consult the defaults for Voice contexts.

Thank you very much for this explanation - I can now go from the entry
in the list of layout objects (via the links at the top of the entry)
back to the engravers that create them and then from there (via the
link at the end) to the context that the engraver is part of, and know
that I should prefix the layout object name with that.
I'm still left with a puzzle for the ClefModifier layout object:

\version "2.18.2"
{
  c'
 \override Staff.ClefModifier.stencil = #ly:text-interface::print
 \once \override Staff.ClefModifier.text = \markup{T}
 \clef "bass_8"
  c'
}

which I was expecting to find the italic 8 replaced by the character T
(I see that there is no need to replace the stencil in this case as it
is by default ly:text-interface::print)

Richard


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
dak
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

dak
Richard Shann <[hidden email]> writes:

> Thank you very much for this explanation - I can now go from the entry
> in the list of layout objects (via the links at the top of the entry)
> back to the engravers that create them and then from there (via the
> link at the end) to the context that the engraver is part of, and know
> that I should prefix the layout object name with that.
> I'm still left with a puzzle for the ClefModifier layout object:
>
> \version "2.18.2"
> {
>   c'
>  \override Staff.ClefModifier.stencil = #ly:text-interface::print
>  \once \override Staff.ClefModifier.text = \markup{T}
>  \clef "bass_8"
>   c'
> }
>
> which I was expecting to find the italic 8 replaced by the character T
> (I see that there is no need to replace the stencil in this case as it
> is by default ly:text-interface::print)

A markup is not a finished stencil but can be converted to one in a
variety of ways.  ly:text-interface::print uses whatever properties are
set in the text-interface related grob properties, and ClefModifier has
things like

        (color . ,(grob::inherit-parent-property
                   X 'color))
        (font-shape . italic)
        (font-size . -4)

in its definition.  You can override those, or you can use stuff like

    \once \override Staff.ClefModifier.text = \markup \normal-text "T"

in order to override the defaults in the grob definition.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Richard Shann-2
On Fri, 2019-02-22 at 18:03 +0100, David Kastrup wrote:
> Richard Shann <[hidden email]> writes:
>
> > Thank you very much for this explanation - I can now go from the
> > entry
> >
[...]

> > which I was expecting to find the italic 8 replaced by the
> > character T
> > [...]
>
> A markup is not a finished stencil but can be converted to one in a
> variety of ways.  ly:text-interface::print uses whatever properties
> are
> set in the text-interface related grob properties, and ClefModifier
> has
> things like
>
>         (color . ,(grob::inherit-parent-property
>                    X 'color))
>         (font-shape . italic)
>         (font-size . -4)
>
> in its definition.  You can override those, or you can use stuff like
>
>     \once \override Staff.ClefModifier.text = \markup \normal-text
> "T"
>
> in order to override the defaults in the grob definition.

I'm baffled now - if I compile

\version "2.18.2"

  c'
 \once \override Staff.ClefModifier.text = \markup \normal-text "T"
 \clef "bass_8"
  c'
}

The italic 8 is printed as usual - the default text is not overwritten.

Richard



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
dak
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

dak
Richard Shann <[hidden email]> writes:

> On Fri, 2019-02-22 at 18:03 +0100, David Kastrup wrote:
>> Richard Shann <[hidden email]> writes:
>>
>> > Thank you very much for this explanation - I can now go from the
>> > entry
>> >
> [...]
>> > which I was expecting to find the italic 8 replaced by the
>> > character T
>> > [...]
>>
>> A markup is not a finished stencil but can be converted to one in a
>> variety of ways.  ly:text-interface::print uses whatever properties
>> are
>> set in the text-interface related grob properties, and ClefModifier
>> has
>> things like
>>
>>         (color . ,(grob::inherit-parent-property
>>                    X 'color))
>>         (font-shape . italic)
>>         (font-size . -4)
>>
>> in its definition.  You can override those, or you can use stuff like
>>
>>     \once \override Staff.ClefModifier.text = \markup \normal-text
>> "T"
>>
>> in order to override the defaults in the grob definition.
>
> I'm baffled now - if I compile
>
> \version "2.18.2"
> { 
>   c'
>  \once \override Staff.ClefModifier.text = \markup \normal-text "T"
>  \clef "bass_8"
>   c'
> }
>
> The italic 8 is printed as usual - the default text is not overwritten.

Sorry for that.  The reason is that there is some
clefTranspositionFormatter function that completely bypasses the text
callback (and the stencil callback apparently).  I have no idea what the
point with that should be.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Schneidy
In reply to this post by Richard Shann-2
Hi Richard,
How about:

\version "2.18.2"

{
  c'
  %\once \override Staff.ClefModifier.stencil = #ly:text-interface::print
  %\once \override Staff.ClefModifier.text = \markup \normal-text "T"
  \once \override Staff.ClefModifier.stencil =
    #(lambda (grob) (grob-interpret-markup grob #{ \markup "T" #}))
  \clef "F_8"
  c
}

Cheers,
Pierre

Le ven. 22 févr. 2019 à 12:50, Richard Shann <[hidden email]> a écrit :
I've been following up the idea of using markup as stencils:

http://lilypond.org/doc/v2.18/Documentation/notation/modifying-stencils

and have got it working for NoteHead and for Dots (which was my use-
case). But trying to generalize to more layout objects I ran into
trouble. This I expected would replace the change of clef with a "T"
but it does not:

\version "2.18.2"
{
  c'
  \once \override ClefModifier.stencil = #ly:text-interface::print
  \once \override ClefModifier.text = \markup{T}
  \clef bass
  c'
}

Any ideas?

Richard


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Modifying Stencil for Clef

Richard Shann-2
On Sat, 2019-02-23 at 10:16 +0100, Pierre Perol-Schneider wrote:

> Hi Richard,
> How about:
>
> \version "2.18.2"
>
> {
>   c'
>   %\once \override Staff.ClefModifier.stencil = #ly:text-
> interface::print
>   %\once \override Staff.ClefModifier.text = \markup \normal-text "T"
>   \once \override Staff.ClefModifier.stencil = 
>     #(lambda (grob) (grob-interpret-markup grob #{ \markup "T" #}))
>   \clef "F_8"
>   c
> }
>

Thank you - not only is this shorter but the same syntax can be used
for all the grobs I have tried so I've made this the default in Denemo
for the command "Change Stencil". The complete interface looks like
this:
You invoke "Change Stencil" and get offered a choice of grobs, once
chosen you get a markup editor which takes your text and continuously
compiles it using LilyPond to display what the markup will look like in
a pane above your text. When satisfied the syntax above is inserted
with your choice of markup and it then affects the next grob of the
chosen type.

Richard

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user