Align text above clef

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

Align text above clef

Urs Liska-3
Hi,

I have to center-align some texts above and below clefs like in the
attached image.

Before I start fiddling around with the Clef stencil and combine the
markups I'd like to ask if there's a simpler and more straightforward
way to achieve that.

Ideally I'd like to have the markups at a fixed vertical position so
several of those on one system will align properly.

Any suggestions?

Thanks
Urs


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

neue-vorlage-seitenkorrekt.png (45K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Align text above clef

Mats Bengtsson-4
Hi,


On 2018-10-15 11:22, Urs Liska wrote:

> Hi,
>
> I have to center-align some texts above and below clefs like in the
> attached image.
>
> Before I start fiddling around with the Clef stencil and combine the
> markups I'd like to ask if there's a simpler and more straightforward
> way to achieve that.
>
> Ideally I'd like to have the markups at a fixed vertical position so
> several of those on one system will align properly.
How about using the break-alignable-interface, see
http://lilypond.org/doc/v2.19/Documentation/notation/aligning-objects#using-the-break_002dalignable_002dinterface 
?
A starting point could be

\relative c'{
   \clef alto
   \override Score.RehearsalMark.break-align-symbols= #'(clef)
   \override Score.Clef.break-align-anchor-alignment = #CENTER
   \mark "text"
   c e f g
}

    /Mats

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

Re: Align text above clef

Urs Liska-3
Hi Mats,

thank you for the suggestion.


Am 15.10.2018 um 12:54 schrieb Mats Bengtsson:

> Hi,
>
>
> On 2018-10-15 11:22, Urs Liska wrote:
>> Hi,
>>
>> I have to center-align some texts above and below clefs like in the
>> attached image.
>>
>> Before I start fiddling around with the Clef stencil and combine the
>> markups I'd like to ask if there's a simpler and more straightforward
>> way to achieve that.
>>
>> Ideally I'd like to have the markups at a fixed vertical position so
>> several of those on one system will align properly.
> How about using the break-alignable-interface, see
> http://lilypond.org/doc/v2.19/Documentation/notation/aligning-objects#using-the-break_002dalignable_002dinterface 
> ?
> A starting point could be
>
> \relative c'{
>   \clef alto
>   \override Score.RehearsalMark.break-align-symbols= #'(clef)
>   \override Score.Clef.break-align-anchor-alignment = #CENTER
>   \mark "text"
>   c e f g
> }

Well, this does solve the horizontal alignment issue, but I can't use it
because I need always *two* such texts, one above and one below the clef.

Urs

>
>    /Mats
>
> _______________________________________________
> 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: Align text above clef

Urs Liska-3


Am 15.10.2018 um 13:16 schrieb Urs Liska:

> Hi Mats,
>
> thank you for the suggestion.
>
>
> Am 15.10.2018 um 12:54 schrieb Mats Bengtsson:
>> Hi,
>>
>>
>> On 2018-10-15 11:22, Urs Liska wrote:
>>> Hi,
>>>
>>> I have to center-align some texts above and below clefs like in the
>>> attached image.
>>>
>>> Before I start fiddling around with the Clef stencil and combine the
>>> markups I'd like to ask if there's a simpler and more
>>> straightforward way to achieve that.
>>>
>>> Ideally I'd like to have the markups at a fixed vertical position so
>>> several of those on one system will align properly.
>> How about using the break-alignable-interface, see
>> http://lilypond.org/doc/v2.19/Documentation/notation/aligning-objects#using-the-break_002dalignable_002dinterface 
>> ?
>> A starting point could be
>>
>> \relative c'{
>>   \clef alto
>>   \override Score.RehearsalMark.break-align-symbols= #'(clef)
>>   \override Score.Clef.break-align-anchor-alignment = #CENTER
>>   \mark "text"
>>   c e f g
>> }
>
> Well, this does solve the horizontal alignment issue, but I can't use
> it because I need always *two* such texts, one above and one below the
> clef.

OK, I did get into creating a custom stencil, and (building on what I
got from the list last week) it was quite possible. The following code
creates two markup stencils, horizontally aligns them over the clef and
calculate a padding based on the original clef's vertical extent and the
staff symbol positions:

\version "2.19.82"

annotateClef =
#(define-music-function (padding text-above text-below) ((number? 1) markup? markup?)
    #{
      \once \override Staff.Clef.after-line-breaking =
      #(lambda (grob)
         (let*
          ((stencil (ly:clef::print grob))
           ;; miniml distance between center staff line and markup
           (padding-threshold 5)
           ;; reference point of the original clef
           (vpos (/ (ly:grob-property grob 'staff-position) 2))
           ;; upper and lower edges of the clef
           (vextent (ly:stencil-extent stencil Y))
           (clef-top (+ vpos (cdr vextent)))
           (clef-bottom (+ vpos (car vextent)))
           ;; calculate padding acknowledging distance to clef *and* to staff
           (padding-top (max padding (- padding-threshold clef-top)))
           (padding-bottom (max padding (+ padding-threshold clef-bottom)))
           ;; create stencil for upper text and horizontal shift for centering
           (markup-stencil-above (grob-interpret-markup grob text-above))
           (shift-above (- (interval-center (ly:stencil-extent stencil X))
                    (interval-center (ly:stencil-extent markup-stencil-above X))))
           ;; create stencil for lower text
           (markup-stencil-below (grob-interpret-markup grob text-below))
           (shift-below (- (interval-center (ly:stencil-extent stencil X))
                    (interval-center (ly:stencil-extent markup-stencil-below X))))
           ;; combine the three stencils
           (new-stencil
            (ly:stencil-combine-at-edge
             (ly:stencil-combine-at-edge
              stencil Y DOWN
              (ly:stencil-translate-axis markup-stencil-below shift-below X)
              padding-bottom)
             Y UP
             (ly:stencil-translate-axis markup-stencil-above shift-above X)
             padding-top)))
          (ly:grob-set-property! grob 'stencil new-stencil)))
    #})

\relative {
   \annotateClef "Treble" "G"
   \clef treble
   c'1
   \annotateClef "Tenor" "C"
   \clef tenor
   c1
   \annotateClef "Soprano" "C"
   \clef soprano
   c1
}

I have one more general question, though (fortunately it doesn't matter
in my actual example): calculating the padding manually does (I think)
the same as using the outside-staff-padding property in general: it uses
the "bounding box" of the markup as its reference. Is there any way to
have markups be padded above or below the staff so that different text
elements' *baselines* are aligned?

Urs

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