lilypond-devel
[Top][All Lists]
Advanced

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

Re: strut problem,Re: strut problem


From: Jean Abou Samra
Subject: Re: strut problem,Re: strut problem
Date: Sat, 19 Nov 2022 00:10:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1

Le 18/11/2022 à 23:16, Werner LEMBERG a écrit :
Put yourself in the shoes of LilyPond trying to compute the skylines
of this stencil:

(ly:make-stencil "" empty-interval '(-0.3 . 0.7))

According to you, the skyline should be a zero-width spike.  At
which horizontal coordinate is this spike? Any value would be
legitimate.
Well, I don't consider this as something stand-alone but as a markup.
A markup has an anchor, i.e., it starts at a point X, doesn't it?  The
strut would thus have the same horizontal coordinate as X.



A markup is code for a stencil. A markup command does not provide any
information to the outside other than the stencil it returns.

Skylines are a concept defined on stencils, not on markups.

A stencil has an X extent, a Y extent and a stencil expression
(Scheme list). That's all.

Think of it in another way. If LilyPond gave non-empty skylines
to stencils with empty extents, a grob with its stencil set to
#empty-stencil would stop taking no space. Instead, it would take
the space of a point and start influencing the spacing. I think
it should be clear that this is a bad idea.



If \strut needs to have an empty X extent for horizontal spacing
reasons, you will need to use ly:stencil-outline.
Understood now, thanks.  David suggests

```
#(define-markup-command (strut layout props)
    ()
    #:properties ((baseline-skip))
    (make-transparent-box-stencil
                     empty-interval
                     (cons (* -0.3 baseline-skip)
                           (* 0.7 baseline-skip))))
```

and I wonder whether the existing `\strut` command should be changed
to this code.



Well, but this does not make \strut taken into account in
the vertical skylines, does it? If it does, I am not seeing
the effect.

David is right, however, that the make-transparent-box-stencil
helper can be used here. Here is a variation of my second
snippet that uses it:

\version "2.23.81"

#(define-markup-command (strut layout props)
   ()
   #:properties ((baseline-skip))
   (let ((yext (cons (* -0.3 baseline-skip)
                     (* 0.7 baseline-skip))))
     (ly:make-stencil
      (ly:stencil-expr (make-transparent-box-stencil '(0 . 0.05) yext))
      empty-interval
      yext)))

{
  \override TextScript.show-vertical-skylines = ##t
  e'4^\markup { "a" }
  e'4^\markup \concat { \strut "a" }
}

\markup \line { "a" "a" }
\markup \line { "a" \strut "a" }



But this is really walking on thin ice, in my view.

Can we take a step back? What are the use cases for \strut
in the first place? Maybe we can invent something that works
more sanely and fits the same purposes.

For example, you could have a markup command that takes a
string and typesets it while giving it the extents + outline
of a box around it encompassing the height of potential
ascenders and descenders.

Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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