scaling "normal text" font size inside dynamic

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

scaling "normal text" font size inside dynamic

Kieren MacMillan
Hello,

Is there any way to change the font size of the "normal text" portion of mixed dynamic markings, independently from the font size of the dynamic portion? For example, in

   p dolce

I'd like to increase the size of 'dolce' without increasing the size of the 'p'. I am using various functions to knit together dynamics and text, and I have various stylesheets (which use different fonts), so I'd rather not have to hard-code the scaling into each function and duplicate every function in each stylesheet.

Below is an example of one of the functions I use, and the current effect of increasing DynamicText.font-size (which is to increase the entire dynamic).

Thanks,
Kieren.

%%%%  SNIPPET BEGINS
\version "2.19"

dynText = #(define-event-function (parser location dyn expr)
             (markup? markup?)
             (let* (
                     (mark #{ \markup { \dynamic $dyn \hspace #0.2 \normal-text \italic $expr } #})
                     (offset (lambda (grob)
                               (let* (
                                       (layout (ly:grob-layout grob))
                                       (props (ly:grob-alist-chain grob
                                                (ly:output-def-lookup layout
                                                  'text-font-defaults)))
                                       (target-X-extent
                                        (ly:stencil-extent

                                         (ly:text-interface::interpret-markup layout props dyn)
                                         X))
                                       (width (abs
                                               (- (cdr target-X-extent) (car target-X-extent))))
                                       )
                                 (display target-X-extent)
                                 (- 1 (/ width 2))
                                 )
                               )
                       )
                     )
               #{
                 \tweak DynamicText.X-offset #offset
                 #(make-dynamic-script mark)
               #}
               )
             )

{ c''1\dynText "p" "dolce" }

{ \override DynamicText.font-size = #2 c''1\dynText "p" "dolce" }
%%%%  SNIPPET ENDS
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


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

Re: scaling "normal text" font size inside dynamic

tisimst
Hi, Kieren!

On Wed, Aug 2, 2017 at 7:39 PM, Kieren MacMillan [via Lilypond] <[hidden email]> wrote:
Hello,

Is there any way to change the font size of the "normal text" portion of mixed dynamic markings, independently from the font size of the dynamic portion? For example, in

   p dolce

I'd like to increase the size of 'dolce' without increasing the size of the 'p'. I am using various functions to knit together dynamics and text, and I have various stylesheets (which use different fonts), so I'd rather not have to hard-code the scaling into each function and duplicate every function in each stylesheet.

Just put \larger before \normal-text and it will respond to the 'font-size property, but be at a larger point size than the rest of it.

HTH,
Abraham

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scaling "normal text" font size inside dynamic

Kieren MacMillan-2
Hi Abraham,

> Just put \larger before \normal-text and it will respond to the 'font-size property, but be at a larger point size than the rest of it.

But the scaling factor is different depending on the font (x-height, etc.) — so don't I have to do that *inside* each function, and therefore duplicate each function in every stylesheet with a different font? I was hoping there was a more elegant solution…

Thanks,
Kieren.
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


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

Re: scaling "normal text" font size inside dynamic

tisimst
On Thu, Aug 3, 2017 at 6:45 AM, Kieren MacMillan-2 [via Lilypond] <[hidden email]> wrote:
> Just put \larger before \normal-text and it will respond to the 'font-size property, but be at a larger point size than the rest of it.

But the scaling factor is different depending on the font (x-height, etc.) — so don't I have to do that *inside* each function, and therefore duplicate each function in every stylesheet with a different font? I was hoping there was a more elegant solution…

This is the unfortunate reality about fonts. I once tried to find a way by first making a non-printed markup of only the "x" character, getting its Y-extent, then scaling based on that, but I was never successful. Maybe someone else will have a better idea for you, aside from adding another input parameter for to pass in to the 'fontsize markup macro.

Best,
Abraham
Loading...