lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help using math in markup command definition, and a feature req


From: Jean Abou Samra
Subject: Re: Need help using math in markup command definition, and a feature request.
Date: Tue, 09 May 2023 03:06:57 +0200
User-agent: Evolution 3.48.1 (3.48.1-1.fc38)

Le lundi 08 mai 2023 à 20:55 -0400, dfro a écrit :

Fellow music engravers,

I have a feature request. Perhaps, this has been discussed already.

Sometimes, I would like the spacial formatting in a \markup command to respond to changes in fontsize, so that all of the \markup spacing will change proportional to the change in fontsize. I think having \markup formatting commands - like \fs-raise, \fs-lower, \fs-hspace, \fs-vspace, etc. - that respond to changes in \fontsize would be helpful.

First: have you seen the \translate-scaled markup command? It fits the bill in most cases.

Assuming you still want to write custom Scheme code:

I am trying to make a basic define-markup-command function for \raise that would do this for whole number fontsizes, but I do not know how to add math to markup command definitions. Here is my non-working code sketch, so far.

``` \version "2.24.1"

%global font-size variable font-size = #0 %#1

Instead of using a global variable, it is better to read the font size inside the markup command. That makes the command usable in several places in the file with different font sizes. For an example, see the definition of \translate-scaled in the source code:

https://gitlab.com/lilypond/lilypond/-/blob/master/scm/define-markup-commands.scm#L5151

%fs-raise definition #(define-markup-command (fs-raise layout props rs text1) (number? markup?)     (interpret-markup layout props                       (cond

                       ((equal? font-size 0)                         ; I want to create variable r = rs * 1, like this, which does not work, #(define r (* 1 rs))

First, you should not put a # character before the Scheme _expression_. In LilyPond, the # switches to Scheme mode, but here, you are already inside a Scheme _expression_ (through the initial # in #(define-markup-command ...).

The # character is also used by the Scheme language itself; specifically; #(...) is a vector literal. That's not what you want here.

Second, you need to use let here, not define. See

https://extending-lilypond.gitlab.io/en/scheme/local-variables.html

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]