On 5/8/23 21:06, Jean Abou Samra wrote:

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

|


Jean,

I think \translate-scaled will work for me! This is a wonderful tool.  In the following example, \concat allows me to get the symbols closer together. The -.2 values for x in /translate-scaled on the third \markup example do nothing. Is there a way to turn off collision avoidance in \markup? I know about \once \override TextScript.extra-offset = #'(0 . 0) , but that does not scale.

<code start>

\version "2.24.1"

{
  \textLengthOn
  c1^\markup \fontsize #5 { \concat { C \translate-scaled #'(.2 . .4) \fontsize #-1 \flat \fontsize #-2 \column { \translate-scaled #'(.1 . 1.2) 7 \translate-scaled #'(.1 . 2.5) 4 } } }   c1^\markup \fontsize #10 { \concat { C \translate-scaled #'(.2 . .4) \fontsize #-1 \flat \fontsize #-2 \column { \translate-scaled #'(.1 . 1.2) 7 \translate-scaled #'(.1 . 2.5) 4 } } }   c1^\markup \fontsize #5 { C \translate-scaled #'(-.2 . .5) \fontsize #-2 \flat \translate-scaled #'(-.2 . .6) \fontsize #-2 7 }
}

<code end>

Thank you, for the link to the Extending Lilypond website. I figured that I would have to learn about let or lambda. I also thought using # in the function was wrong, but it made a lot of errors go away when I was trying things.

Also, I agree that passing the fontsize to the function directly, rather than using a global variable, is more usable.


Peace,

David

Reply via email to