Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fanninpm opened this issue Nov 13, 2023 · 0 comments
Open

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

fanninpm opened this issue Nov 13, 2023 · 0 comments

Comments

@fanninpm
Copy link

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:

  • In LilyPond v2.25.5 and above, instead of fonts.roman, it needs to be fonts.serif, according to this patch.
  • In LilyPond v2.25.6 and above, instead of fonts.{serif,sans,typewriter}, it probably needs to be property-defaults.fonts.{serif,sans,typewriter}, according to this patch.

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()
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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant