jperon / lyluatex

Alternative à lilypond-book pour lualatex
MIT License
56 stars 11 forks source link

Make lyluatex work with LilyPond v2.25.5 and newer #317

Open fanninpm opened 9 months ago

fanninpm commented 9 months ago

I was tracking down the source of a bug having to do with typeface preferences not getting transmitted to LilyPond. I came across #309, which seems to match up with the symptoms I'm observing with LilyPond v2.25.11 (the version I got when I installed LilyPond using brew install lilypond --HEAD to dodge another LilyPond bug in v2.24.2 having to do with GhostScript). Unfortunately, the fix supplied by @lemzwerg in that issue no longer works as of LilyPond v2.25.6 because of two changes I found:


I'm not a Lua expert, but if I had to guess at what the code would look like, this would be it:

Lua code at function Score:ly_fonts() ```lua function Score:ly_fonts() if self['pass-fonts'] then local fonts_def if self:lilypond_version() >= ly.v{2, 25, 6} then fonts_def = [[property-defaults.fonts.serif = "%s" property-defaults.fonts.sans = "%s" property-defaults.fonts.typewriter = "%s"]] else if self:lilypond_version() >= ly.v{2, 25, 5} then fonts_def = [[fonts.serif = "%s" fonts.sans = "%s" fonts.typewriter = "%s"]] else if self:lilypond_version() >= ly.v{2, 25, 4} then fonts_def = [[fonts.roman = "%s" fonts.sans = "%s" fonts.typewriter = "%s"]] else fonts_def = [[ #(define fonts (make-pango-font-tree "%s" "%s" "%s" (/ staff-height pt 20))) ]] end return fonts_def:format(self.rmfamily, self.sffamily, self.ttfamily) else return '%% fonts not set' end end ```

Workaround

It's possible to define a \paper block in the LilyPond code itself. For example,

\paper {
    property-defaults.fonts.serif = "Alegreya"
}