Creating custom articulation using regular text font

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

Creating custom articulation using regular text font

Urs Liska-3

I'm trying to create an articulation printing a glyph from the "regular" text font.

Copying from this (working) script definition list:

#(define asterisk-list
   `("asterisk"
      . ((stencil . ,ly:text-interface::print)
         (text . ,#{ \markup \musicglyph "pedal.*" #})
         ; any other properties
         (padding . 0.5)
         (avoid-slur . around)
         (direction . ,DOWN)
         (script-priority . 125)
         )))

I came up with the following:

#(define trill-list
   `("trill"
      . ((stencil . ,ly:text-interface::print)
         (text . ,#{ \markup "T" #})
         ; any other properties
         (padding . 0.5)
         (avoid-slur . around)
         (direction . ,DOWN)
         (script-priority . 75)
         )))

But when I integrate this and compile a file I get no output for the articulation and instead an error message, saying

programming error: Cannot get a text stencil from this font


    

I don't quite see why \markup "T" doesn't successfully create a stencil where in a comparable place \markup \musicglyph ... does.

Any suggestions what I could do about it?

Thanks Urs


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

Re: Creating custom articulation using regular text font

Urs Liska-3

Hi,

I haven't got any further, but ...

Am 20.02.19 um 11:53 schrieb Urs Liska:

I'm trying to create an articulation printing a glyph from the "regular" text font.

...


I moved all the relevant code into an MWE, which might trigger more ideas than the abstract excerpt I originally posted.

The problem is that I can create a custom articulation using a stencil made from \markup \musicglyph "something" but not from \markup "Something".

I'd be really thankful about any push in the right direction, since I have no clue as to where even start searching.

Best
Urs

\version "2.19.82"

% The "asterisk" *does* work properly
#(define asterisk-list
   `("asterisk"
      . ((stencil . ,ly:text-interface::print)
         (text . ,#{ \markup \musicglyph "pedal.*" #})
         ; any other properties
         (padding . 0.5)
         (avoid-slur . around)
         (direction . ,DOWN)
         (script-priority . 125)
         )))

% The "trill" fails, complaining in a programming error that it "Cannot get a text stencil from this font"
#(define trill-list
   `("trill"
      . ((stencil . ,ly:text-interface::print)
         (text . ,#{ \markup "T" #})
         ; any other properties
         (padding . 0.5)
         (avoid-slur . around)
         (direction . ,DOWN)
         (script-priority . 75)
         )))

%% A macro setting the lists from above in the copy of `default-script-alist´
%% For now, every new script has to be inserted in a single run.
%% TODO
%% Probably better to do simpler list processing with append, cons etc
#(define-macro (set-my-script-alist! ls-1 ls-2)
   "Creates a new key-value-pair, taken from ls-2, in ls-1"
   `(set! ,ls-1
          (if (and (pair? ,ls-2) (pair? (cadr ,ls-2)))
              (assoc-set! ,ls-1 (car ,ls-2) (cdr ,ls-2))
              (begin
               (ly:warning (_"Unsuitable list\n\t~a \n\tdetected, ignoring. ") ,ls-2)
               ,ls-1))))

#(set-my-script-alist! default-script-alist asterisk-list)
#(set-my-script-alist! default-script-alist trill-list)

\layout {
  \context {
    \Score
    scriptDefinitions = #default-script-alist
  }
}

asterisk-artic = #(make-articulation "asterisk")
trill-artic = #(make-articulation "trill")



tt =
#(define-event-function ()()
   #{
     -\trill-artic
   #})

asterisk =
#(define-event-function ()()
     #{
       -\tweak font-size 0
       -\asterisk-artic
     #})


\relative {
  c'' \asterisk
  c \tt
}

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

Re: Creating custom articulation using regular text font

Jan-Peter Voigt
Hi Urs,

in an articulation event the font is emmentaler and not a normal one.
So in the trill-list part you have to switch back to normal text with
\markup \normal-text "T"

HTH
Jan-Peter

Am 20.02.19 um 17:23 schrieb Urs Liska:

> Hi,
>
> I haven't got any further, but ...
>
> Am 20.02.19 um 11:53 schrieb Urs Liska:
>>
>> I'm trying to create an articulation printing a glyph from the
>> "regular" text font.
>>
>> ...
>
>
> I moved all the relevant code into an MWE, which might trigger more
> ideas than the abstract excerpt I originally posted.
>
> The problem is that I can create a custom articulation using a stencil
> made from \markup \musicglyph "something" but not from \markup "Something".
>
> I'd be really thankful about any push in the right direction, since I
> have no clue as to where even start searching.
>
> Best
> Urs
>
> \version "2.19.82"
>
> % The "asterisk" *does* work properly
> #(define asterisk-list
>    `("asterisk"
>       . ((stencil . ,ly:text-interface::print)
>          (text . ,#{ \markup \musicglyph "pedal.*" #})
>          ; any other properties
>          (padding . 0.5)
>          (avoid-slur . around)
>          (direction . ,DOWN)
>          (script-priority . 125)
>          )))
>
> % The "trill" fails, complaining in a programming error that it "Cannot get a text stencil from this font"
> #(define trill-list
>    `("trill"
>       . ((stencil . ,ly:text-interface::print)
>          (text . ,#{ \markup "T" #})
>          ; any other properties
>          (padding . 0.5)
>          (avoid-slur . around)
>          (direction . ,DOWN)
>          (script-priority . 75)
>          )))
>
> %% A macro setting the lists from above in the copy of `default-script-alist´
> %% For now, every new script has to be inserted in a single run.
> %% TODO
> %% Probably better to do simpler list processing with append, cons etc
> #(define-macro (set-my-script-alist! ls-1 ls-2)
>    "Creates a new key-value-pair, taken from ls-2, in ls-1"
>    `(set! ,ls-1
>           (if (and (pair? ,ls-2) (pair? (cadr ,ls-2)))
>               (assoc-set! ,ls-1 (car ,ls-2) (cdr ,ls-2))
>               (begin
>                (ly:warning (_"Unsuitable list\n\t~a \n\tdetected, ignoring. ") ,ls-2)
>                ,ls-1))))
>
> #(set-my-script-alist! default-script-alist asterisk-list)
> #(set-my-script-alist! default-script-alist trill-list)
>
> \layout {
>   \context {
>     \Score
>     scriptDefinitions = #default-script-alist
>   }
> }
>
> asterisk-artic = #(make-articulation "asterisk")
> trill-artic = #(make-articulation "trill")
>
>
>
> tt =
> #(define-event-function ()()
>    #{
>      -\trill-artic
>    #})
>
> asterisk =
> #(define-event-function ()()
>      #{
>        -\tweak font-size 0
>        -\asterisk-artic
>      #})
>
>
> \relative {
>   c'' \asterisk
>   c \tt
> }
>
>
> _______________________________________________
> 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: Creating custom articulation using regular text font

Urs Liska-3
Hi Jan-Peter,

thank you very much, this was exactly what I needed!
And your solution came *exactly* in the moment when I had to decide
whether I should skip the three affected snippets instead of including
them in the upcoming set for review :-)

Best
Urs

Am 20.02.19 um 18:25 schrieb Jan-Peter Voigt:

> Hi Urs,
>
> in an articulation event the font is emmentaler and not a normal one.
> So in the trill-list part you have to switch back to normal text with
> \markup \normal-text "T"
>
> HTH
> Jan-Peter
>
> Am 20.02.19 um 17:23 schrieb Urs Liska:
>> Hi,
>>
>> I haven't got any further, but ...
>>
>> Am 20.02.19 um 11:53 schrieb Urs Liska:
>>> I'm trying to create an articulation printing a glyph from the
>>> "regular" text font.
>>>
>>> ...
>>
>> I moved all the relevant code into an MWE, which might trigger more
>> ideas than the abstract excerpt I originally posted.
>>
>> The problem is that I can create a custom articulation using a stencil
>> made from \markup \musicglyph "something" but not from \markup "Something".
>>
>> I'd be really thankful about any push in the right direction, since I
>> have no clue as to where even start searching.
>>
>> Best
>> Urs
>>
>> \version "2.19.82"
>>
>> % The "asterisk" *does* work properly
>> #(define asterisk-list
>>     `("asterisk"
>>        . ((stencil . ,ly:text-interface::print)
>>           (text . ,#{ \markup \musicglyph "pedal.*" #})
>>           ; any other properties
>>           (padding . 0.5)
>>           (avoid-slur . around)
>>           (direction . ,DOWN)
>>           (script-priority . 125)
>>           )))
>>
>> % The "trill" fails, complaining in a programming error that it "Cannot get a text stencil from this font"
>> #(define trill-list
>>     `("trill"
>>        . ((stencil . ,ly:text-interface::print)
>>           (text . ,#{ \markup "T" #})
>>           ; any other properties
>>           (padding . 0.5)
>>           (avoid-slur . around)
>>           (direction . ,DOWN)
>>           (script-priority . 75)
>>           )))
>>
>> %% A macro setting the lists from above in the copy of `default-script-alist´
>> %% For now, every new script has to be inserted in a single run.
>> %% TODO
>> %% Probably better to do simpler list processing with append, cons etc
>> #(define-macro (set-my-script-alist! ls-1 ls-2)
>>     "Creates a new key-value-pair, taken from ls-2, in ls-1"
>>     `(set! ,ls-1
>>            (if (and (pair? ,ls-2) (pair? (cadr ,ls-2)))
>>                (assoc-set! ,ls-1 (car ,ls-2) (cdr ,ls-2))
>>                (begin
>>                 (ly:warning (_"Unsuitable list\n\t~a \n\tdetected, ignoring. ") ,ls-2)
>>                 ,ls-1))))
>>
>> #(set-my-script-alist! default-script-alist asterisk-list)
>> #(set-my-script-alist! default-script-alist trill-list)
>>
>> \layout {
>>    \context {
>>      \Score
>>      scriptDefinitions = #default-script-alist
>>    }
>> }
>>
>> asterisk-artic = #(make-articulation "asterisk")
>> trill-artic = #(make-articulation "trill")
>>
>>
>>
>> tt =
>> #(define-event-function ()()
>>     #{
>>       -\trill-artic
>>     #})
>>
>> asterisk =
>> #(define-event-function ()()
>>       #{
>>         -\tweak font-size 0
>>         -\asterisk-artic
>>       #})
>>
>>
>> \relative {
>>    c'' \asterisk
>>    c \tt
>> }
>>
>>
>> _______________________________________________
>> 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

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

Re: Creating custom articulation using regular text font

tisimst
Hi, Urs!

On Wed, Feb 20, 2019 at 10:41 AM Urs Liska <[hidden email]> wrote:
Hi Jan-Peter,

thank you very much, this was exactly what I needed!
And your solution came *exactly* in the moment when I had to decide
whether I should skip the three affected snippets instead of including
them in the upcoming set for review :-)

Best
Urs

Am 20.02.19 um 18:25 schrieb Jan-Peter Voigt:
> Hi Urs,
>
> in an articulation event the font is emmentaler and not a normal one.
> So in the trill-list part you have to switch back to normal text with
> \markup \normal-text "T"

To expound further upon what Jan-Peter pointed out, the real culprit here is that the 'font-encoding property is rightfully set to 'fetaMusic, but since none of the fonts tied to this encoding have "T" in it, thus the failure. To have it print characters from a text font, the encoding must be changed to 'latin1 instead, as a bare minimum. \normal-text does this under the covers in addition to setting some other useful font properties (i.e., font-family = roman, font-shape = upright, font-series = medium), but just thought I'd share *why* this works for posterity.

Best,
Abraham

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