[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating a stencil from a markup
From: |
Thomas Morley |
Subject: |
Re: Creating a stencil from a markup |
Date: |
Thu, 15 Dec 2016 00:23:16 +0100 |
2016-12-14 21:59 GMT+01:00 David Nalesnik <address@hidden>:
> On Wed, Dec 14, 2016 at 2:57 PM, David Nalesnik
> <address@hidden> wrote:
>> Hi Simon,
>>
>> On Wed, Dec 14, 2016 at 2:20 PM, Simon Albrecht <address@hidden> wrote:
>>> Hello everybody,
>>>
>>> I’d like to add a caesura sign on top of a barline by modifying the
>>> barline’s stencil. Here’s my attempt:
>>>
>>> %%%%%%%%%%%%%%%%%%
>>> \version "2.19.49"
>>>
>>> {
>>> 1
>>> \once\override BarLine.stencil =
>>> #(ly:stencil-combine-at-edge
>>> ly:bar-line::print
>>> 1 ; y-axis
>>> 1 ; on top
>>> (interpret-markup layout props (make-musicglyph-markup
>>> "scripts.caesura.curved"))
>>> 2) %padding
>>> 1
>>> }
>>> %%%%%%%%%%%%%%%%%%
>>>
>>> However, layout is an unbound variable here (and so is props, I assume). How
>>> to do it correctly?
>>>
>>
>> Try:
>>
>> {
>> 1
>> \once\override Staff.BarLine.stencil =
>> #(lambda (grob)
>> (let ((layout (ly:grob-layout grob)))
>> (ly:stencil-combine-at-edge
>> (ly:bar-line::print grob)
>> 1 ; y-axis
>> 1 ; on top
>> (interpret-markup
>> layout
>> (ly:grob-alist-chain grob (ly:output-def-lookup layout
>> 'text-font-defaults))
>> (make-musicglyph-markup "scripts.caesura.curved"))
>> 2))) %padding
>> 1
>> }
>>
>> Best,
>> David
>
>
> For documentation, look at ly:text-interface::interpret-markup here:
> http://lilypond.org/doc/v2.18/Documentation/internals/scheme-functions
You could also use 'grob-interpret-markup' from output-lib.scm.
Usually I's recommend to use ly:stencil-aligned-to as well, to get a
center-aligned stencil. But the font-metrics for
"scripts.caesura.curved" are not symmetric.
Anyway here the code using both (\box only for checking)
\once\override Staff.BarLine.stencil =
#(lambda (grob)
(ly:stencil-combine-at-edge
(ly:bar-line::print grob)
1 ; y-axis
1 ; on top
(ly:stencil-aligned-to
(grob-interpret-markup
grob
#{ \markup \box \musicglyph #"scripts.caesura.curved" #})
X
CENTER)
2))
Cheers.
Harm
Re: Creating a stencil from a markup, Simon Albrecht, 2016/12/14