Le mardi 14 février 2023 à 13:02 +0100, Valentin Petzel a écrit :
> As far as I see this is not the problem. Footnotes appear to be simply 
> stacked  
> by extent, not by baseline. This already creates issues with footnotes  
> extending over multiple lines, as the spacing between different footnotes 
> will  
> be less than the spacing between different lines of footnotes.
> 
> Meanwhile we could easily get an acceptable behaviour (I suppose) by changing 
>  
> from a equal baseline distance model to a model that aligns baselines to some 
>  
> grid, such as this:
> 
> fns = \markuplist {  
>   "Meter change."  
>   "Chord stem."  
>   "Bar line."  
>   \justify { Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eget 
>  
> ante venenatis mi consectetur ornare. Cras facilisis dictum venenatis. }  
>   "Key change."  
> }
> 
> \markup\column\fns
> 
> #(define (cumsum . x)  
>    (define (impl init a . b)  
>      (if (null? b)  
>          (list (+ init a))  
>          (cons (+ init a) (apply impl (cons (+ a init) b)))))  
>    (apply impl (cons 0 x)))
> 
> 
> \markup\vspace #3
> 
> #(define-markup-command (column-to-grid layout props ml) (markup-list?)  
>    #:properties ((baseline-skip 3.5))  
>    (let* ((iml (interpret-markup-list layout props ml))  
>           (exts (map (lambda (s) (ly:stencil-extent s Y)) iml))  
>           (under-bl-exts (map car exts))  
>           (under-bl-grids (map (lambda (x) (* (1- (ceiling (/ x baseline-  
> skip))) baseline-skip)) under-bl-exts))  
>           (grid-points (cons 0 (apply cumsum under-bl-grids)))  
>           (moved-iml (map (lambda (stc amt) (ly:stencil-translate-axis stc 
> amt  
> Y)) iml grid-points)))  
>      (display under-bl-exts)  
>      (apply ly:stencil-add moved-iml)))
> 
> \markup\column-to-grid\fns
> 
> \markup\vspace #3
> 
> \markup\override #'(baseline-skip . 2.5) \column-to-grid\fns



That is merely a heuristic. It will fail in a case like

```
\version "2.24.0"

#(define-markup-command (print-ext layout props arg) (markup?)
   (let ((stil (interpret-markup layout props arg)))
     (ly:message "~s" (ly:stencil-extent stil Y))
     stil))

fns = \markuplist {
  "Meter change."
  "Chord stem."
  "Bar line."
  \justify { #@(make-list 200 (list "IJKLM" "abcdefghij")) }
  "Key change."
}

#(define (cumsum . x)
   (define (impl init a . b)
     (if (null? b)
         (list (+ init a))
         (cons (+ init a)
               (apply impl
                      (+ a init)
                      b))))
   (apply impl 0 x))


#(define-markup-command (column-to-grid layout props ml) (markup-list?)
   #:properties ((baseline-skip 3.5))
   (let* ((iml (interpret-markup-list layout props ml))
          (exts (map (lambda (s) (ly:stencil-extent s Y)) iml))
          (under-bl-exts (map car exts))
          (under-bl-grids (map (lambda (x) (* (1- (ceiling (/ x 
baseline-skip))) baseline-skip)) under-bl-exts))
          (grid-points (cons 0 (apply cumsum under-bl-grids)))
          (moved-iml (map (lambda (stc amt) (ly:stencil-translate-axis stc amt 
Y)) iml grid-points)))
     (apply ly:stencil-add moved-iml)))


\markup\override #'(baseline-skip . 2.05) \column-to-grid\fns
```

because I sneakily inserted ascenders and descenders so that some of the lines 
need to be spaced apart by a tiny bit more than `baseline-skip`.

As an alternative to my "extra stencil data" idea, which was a bit hasty, one 
could conceivably let `\footnote` just accept a markup list and deal with it. 
Then it could use `\column` or whatever to achieve equal spacing of all lines.

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

Reply via email to