jperon / lyluatex

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

Can staff size variable be something other than a counter? #1

Closed rpspringuel closed 9 years ago

rpspringuel commented 9 years ago

By default, Lilypond uses a staff size of 20 which prints the lyrics in 12pt font. Since I want the lyrics text size to match the font size of the rest of the document, this means that in documents where the font size isn't 12 pt, I have to change the Lilypond staff size.

First, the universal variable for default staffsize is already a big step up on lilypond-book (where the staffsize has to be specified for each inclusion separately). However, the fact that it's a counter limits what I can do with it since counters are limited to integers. In my current projects using lilypond-book, I use a scheme expression for the staff size in order to facilitate the scaling. For example staffsize=(* 20 17/12) rescales the music for a 17pt large-print edition. Would it be possible to change the staffsize variable so that it can hold something like this?

jperon commented 9 years ago

Could you test last commit, please ? It should work like this. On a further step, I think I'll add a command to automatically scale default staffsize pending on document's font size.

rpspringuel commented 9 years ago

Tested and found that while \renewcommand{\staffsize}{(* 20 17/12)} doesn't work, \renewcommand{\staffsize}{(20*17/12)} does. Since the first is the Scheme syntax for the math (in particular the multiplication) and the second is Lua syntax, I'm guessing that Lua is trying to process the contents of \staffsize before passing it on to Lilypond rather than simply treating it as a string to be passed along. However, I actually don't mind, and indeed prefer, that in this case. Lua's syntax for mathematical operations is much more natural than Scheme's.

So, bottom line: what you did works and is, I think, better than the equivalent in lilypond-book.

jperon commented 9 years ago

Perfect ! I leave this open till I've made what I told about auto scaling. Thank you !

jperon commented 9 years ago

19d85ff should definitely fix this issue ; feel free to re-open it if there are bugs. From now, if \staffsize is defined to 0, scores will be auto-scaled to stick with font size.