[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Specific Lyric and CHordname font size
From: |
Kieren MacMillan |
Subject: |
Re: Specific Lyric and CHordname font size |
Date: |
Sun, 29 Sep 2024 12:52:01 -0400 |
Hi Walt,
> Is it possible to set a specific chordname and lyric font size? I see that
> \markup can specify an abs font size. I think I'm close with using font size
> #3.5 to get to a 16pt font for example. Is that the only say to specify font
> size in Chords - as a multiple of the global size?
That’s the only way using built-in functions… However, here’s a function I use
which allows me to set any grob font-size by absolute font size:
%%% SNIPPET BEGINS
\version "2.24.4"
allowGrobCallback =
#(define-scheme-function (parser location syms) (symbol-list?)
(let ((interface (car syms))
(sym (cadr syms)))
#{
\with {
\consists #(lambda (context)
`((acknowledgers .
((,interface . ,(lambda (engraver grob
source-engraver)
(let ((prop (ly:grob-property grob
sym)))
(if (procedure? prop)
(ly:grob-set-property! grob sym (prop grob)))
))))
))
)
}
#}))
absFontSize =
#(define-scheme-function (parser location pt)(number?)
(lambda (grob)
(let* ((layout (ly:grob-layout grob))
(ref-size (ly:output-def-lookup (ly:grob-layout grob)
'text-font-size 12)))
(magnification->font-size (/ pt ref-size))
)))
\layout {
\context {
\Score
\allowGrobCallback font-interface.font-size
}
}
\markup {
"default font size:" C
\hspace #2
\fontsize #2 { "\fontsize #2:" C }
\hspace #2
\abs-fontsize #16 { "\abs-fontsize #16:" C }
}
ch = \chordmode { c }
\score {
<<
\new ChordNames {\ch }
\new Lyrics \lyricmode { "default lyric size: " C }
>>
}
\score {
\layout {
\context {
\ChordNames
\override ChordName.font-size = #3.5
}
\context {
\Lyrics
\override LyricText.font-size = #3.5
}
}
<<
\new ChordNames {\ch }
\new Lyrics \lyricmode { "LyricText.font-size = #3.5: " C }
>>
}
\score {
\layout {
\context {
\ChordNames
\override ChordName.font-size = \absFontSize #16
}
}
<<
\new ChordNames {\ch }
\new Lyrics \lyricmode { "LyricText.font-size = #3.5: " C }
>>
}
%%% SNIPPET ENDS
See <https://lists.gnu.org/archive/html/lilypond-user/2024-09/msg00023.html>
[and the rest of that thread] if you’re interested in a deeper dive on the
whole “absolute font sizes in Lilypond” issue…
Hope this helps!
Kieren.
______________________________________________
My work day may look different than your work day. Please do not feel obligated
to read or respond to this email outside of your normal working hours.