Hello, Basically you want to scale the baseline-skip along with the staff size (the reason for this is that measurement is in global staff spaces, not in layout staff spaces).
You can achieve this in multiple ways:
Version 0: Simply use the staff space as baseline-skip
Version 1: Add a little markup trick to scale arbitrary markup properties by
the staff space (include e.g. parentheses parameters).
Version 2: Extract the actual line positions and staff space from the Staff
symbol and place a symbol between all note lines
Cheers,
Valentin
Am Sonntag, 29. Jänner 2023, 10:16:43 CET schrieb Rip _Mus:
> Hello,
> please, take a look:
>
> %%%
> \version "2.24.0"
>
> xclefon = {
> \set Staff.clefPosition = #3
> \override Staff.Clef.stencil = #(lambda (grob)
> (parenthesize-stencil
> (grob-interpret-markup grob
> #{ \markup
> \override #'(baseline-skip . 0.8)
> \teeny \center-column {
> \musicglyph "noteheads.s2cross"
> \musicglyph "noteheads.s2cross"
> \musicglyph "noteheads.s2cross"
> \musicglyph "noteheads.s2cross"
> }
> #})
> 0.1
> 0.5
> 0.5
> 0))
> }
>
> \score {
> {
> c'4
> \xclefon
> c'4
> }
> \layout { #(layout-set-staff-size 16) }
> }
> %%%
>
> in "\override #'(baseline-skip . 0.8)" I'm trying to scale the
> baseline-skip according to the part staff size (16), in fact 16/20 =
> 0.8. I'd like to make this snippet more generic.
> I tried to point, from within the markup, to the Clef grob staff-symbol
> property, to get the staff size, but without success.
> Could you please help me solve?
>
> Thank you
>
> Rip_mus
#(define-markup-command (scale-to-unit layout props arg)
(markup?)
(let* ((layout-text-font-size
(ly:output-def-lookup layout 'text-font-size 11))
(paper-text-font-size
(ly:output-def-lookup
(ly:parser-lookup '$defaultpaper)
'text-font-size 11))
(unit (/ layout-text-font-size paper-text-font-size))
(stc (interpret-markup layout props arg))
(stc-ext (ly:stencil-extent stc Y))
(stc-ext (interval-length stc-ext))
(stc (ly:stencil-scale stc (/ 1 stc-ext) (/ 1 stc-ext))))
(ly:stencil-scale stc unit unit)))
xclefon = {
\set Staff.clefPosition = #3
\override Staff.Clef.stencil = #(lambda (grob)
(let* ((line-thickness (ly:output-def-lookup
(ly:grob-layout grob)
'line-thickness))
(staff-sym (ly:grob-object grob 'staff-symbol))
(staff-space (ly:staff-symbol-staff-space staff-sym))
(thickness (ly:grob-property staff-sym 'thickness 1))
(extra-pad (* staff-space 0.15))
(pad (+ (* thickness line-thickness) extra-pad))
(line-count (ly:grob-property staff-sym 'line-count 5))
(line-pos (ly:grob-property staff-sym 'line-positions
(iota line-count
(* 2 (- (floor-quotient line-count 2)))
2)))
(line-pos (sort line-pos >))
(holes (map - line-pos (cdr line-pos)))
(holes (map (lambda (x) (/ x 2)) holes))
(holes-scaled (map (lambda (x) (* x staff-space)) holes))
(base-stencil (grob-interpret-markup grob (markup #:musicglyph "noteheads.s2cross")))
(ext-y (interval-length (ly:stencil-extent base-stencil Y)))
(fact (/ (- staff-space pad) ext-y))
(base-stencil-scaled (ly:stencil-scale base-stencil fact fact))
(hole-stencils (map (lambda (x)
(ly:stencil-scale base-stencil-scaled
1 (/ (- x pad) (- 1 pad))))
holes))
(stc-col (stack-stencils Y DOWN pad hole-stencils))
(fact (* staff-space (/ (- (first line-pos) (last line-pos)) 8)))
(par-stencil (parenthesize-stencil stc-col (* 0.1 fact) (* 0.4 fact) 0.1 0))
(ext-y (ly:stencil-extent stc-col Y))
(max-pos (car line-pos))
(shift (- (* (- max-pos 3) staff-space 1/2) (/ extra-pad 2))))
(ly:stencil-translate-axis (ly:stencil-aligned-to par-stencil Y UP) shift Y)
))
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 20) }
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 16) }
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 12) }
}
\score {
<<
\new Staff \with { \magnifyStaff #1.5 } {
c'4
\xclefon
c'4
}
\new Staff \with { \magnifyStaff #1 } {
c'4
\xclefon
c'4
}
\new Staff \with { \magnifyStaff #0.5 } {
c'4
\xclefon
c'4
}
\new Staff \with { \override StaffSymbol.line-positions = #'(7 3 0 -2 -4) } {
c'4
\xclefon
c'4
}
>>
\layout { #(layout-set-staff-size 20) }
}
%%%#(define-markup-command (par-relative layout props pars arg)
(list? markup?)
#:properties ((font-size 0))
(let* ((layout-text-font-size
(ly:output-def-lookup layout 'text-font-size 11))
(paper-text-font-size
(ly:output-def-lookup
(ly:parser-lookup '$defaultpaper)
'text-font-size 11))
(unit (/ layout-text-font-size paper-text-font-size))
(unit (* unit (magstep font-size)))
(par-vals (map (lambda (par) (chain-assoc-get par props)) pars))
(par-vals-scaled (map (lambda (val) (if (number? val) (* val unit) val)) par-vals))
(new-props (map cons pars par-vals-scaled))
(new-props (filter (lambda (x) (cdr x)) new-props)))
(interpret-markup layout (cons new-props props) arg)))
xclefon = {
\set Staff.clefPosition = #3
\override Staff.Clef.stencil = #(lambda (grob)
(grob-interpret-markup grob
#{ \markup
\override #'((baseline-skip . 1) (thickness . 1.5) (size . 1.5))
\par-relative #'(baseline-skip size)
\parenthesize
\center-column {
#@(make-list 4 #{ \markup\fontsize #-3 \musicglyph "noteheads.s2cross" #})
}
#}))
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 20) }
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 16) }
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 12) }
}
\score {
<<
\new Staff \with { \magnifyStaff #1.5 } {
c'4
\xclefon
c'4
}
\new Staff \with { \magnifyStaff #1 } {
c'4
\xclefon
c'4
}
\new Staff \with { \magnifyStaff #0.5 } {
c'4
\xclefon
c'4
}
>>
\layout { #(layout-set-staff-size 20) }
}
%%%xclefon = {
\set Staff.clefPosition = #3
\override Staff.Clef.stencil = #(lambda (grob)
(grob-interpret-markup grob
#{ \markup
\override #`(baseline-skip . ,(ly:staff-symbol-staff-space grob))
\parenthesize
\center-column {
#@(make-list 4 #{ \markup\fontsize #-3 \musicglyph "noteheads.s2cross" #})
}
#}))
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 20) }
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 16) }
}
\score {
{
c'4
\xclefon
c'4
}
\layout { #(layout-set-staff-size 12) }
}
\score {
<<
\new Staff \with { \magnifyStaff #1.5 } {
c'4
\xclefon
c'4
}
\new Staff \with { \magnifyStaff #1 } {
c'4
\xclefon
c'4
}
\new Staff \with { \magnifyStaff #0.5 } {
c'4
\xclefon
c'4
}
>>
\layout { #(layout-set-staff-size 20) }
}
%%%
signature.asc
Description: This is a digitally signed message part.
