Managing Alternative Fonts with LilyPond

Oh my, it’s been quite some time since my last post – fortunately there has been at least a guest post recently and there are more in the pipeline. I have been working hard under the hood and there are exciting things going on, but nothing was in a state to be presented here. Now finally I can break the silence and write about one of the topics, at the same time providing some glimpses into other parts of current development in LilyPond’s ecosystem.

As you know (if not: it was announced in “LilyPond’s Look & Feel”) Abraham Lee has enabled LilyPond to use alternative notation fonts, and he already has provided an impressive range of fonts with various styles that are available from In a two part series I’ll introduce you to this new world of stylistic variety that has become possible through Abraham’s work and that openLilyLib makes easily accessible now.

Today we’ll take a first tour through LilyPond’s font handling in general – as it has originally been designed, as it has been until now, and as it will be from now on. In the next post I’ll take the presentation of “Arnold”, a new font Abraham created upon my suggestion, as an opportunity to dig slightly deeper into this topic and show you the tools provided by openLilyLib in some more detail.

Accessing Alternative Fonts – Then and Now

As mentioned in my earlier announcement LilyPond wasn’t originally designed to use alternative fonts, and this was one of the more severe limitations with LilyPond. When I had the opportunity to talk with representatives of several major publishing houses the option of integrating custom fonts to achieve their house styles was one of the first questions that usually arose. When Simon Tatham created the first available replacement font one had to actually exchange the font files so LilyPond wouldn’t even notice that the font had changed. This is a somewhat hacky and non-trivial approach that is described on the font’s home page.

As of Lilypond 2.19.12 this changed, and for the current stable version 2.18 there is a reasonably simple patch to make it work. Now there is a single function available to select any compatible notation font that has been copied to LilyPond’s font directories. The following example simply shows the default values.

\paper {
  #(define fonts
      #:music "emmentaler"
      #:brace "emmentaler"
      #:roman "Century Schoolbook L"
      #:sans "sans-serif"
      #:typewriter "monospace"
      #:factor (/ staff-height pt 20)

This syntax allows you to choose which fonts to change and which ones to leave at these default values, so the following would be sufficient to switch the notation font (general and brace) to the LilyJAZZ font:

\paper {
  #(define fonts
      #:music "lilyjazz"
      #:brace "lilyjazz"
      #:factor (/ staff-height pt 20)

The process of getting and using the alternative fonts is described in detail on the documentation page on However, getting the fonts to be recognized in the first place is still a little bit awkward, as you can’t simply “install” the fonts to your operating system but have to copy them inside LilyPond’s own font folders. Concretely you have to:

  • Download the archive file for a font from the website
  • Extract it to disk
  • Copy the font files from two folders to two folders inside your LilyPond installation

As this depends on the actual LilyPond installation you’ll have to repeat that step for any additional LilyPond installation you may have (and developers can have numerous different builds in parallel to test different features), and also you’d have to repeat this every time you update LilyPond. The issue can be slightly alleviated by creating symbolic links instead of physical copies inside the LilyPond installations – yet this has to be done again each time too.

Accessing Alternative Fonts – The Future

Well, all of this was yesterday – but the future is bright πŸ™‚ .
Keeping your collection of alternative fonts up-to-date has become a breeze now, and using these fonts has become much simpler and even more powerful as well, thanks to two of my latest projects.

Automating Font Management

With install-lily-fonts managing a repository of alternative fonts has become a near-automatic process. This tool maintains a local repository and a catalog of fonts and versions and uses this to automatically detect any new or updated versions on the server. It then downloads new archives if necessary and “installs” them to one or multiple LilyPond installation(s). So regularly running this program (at least after updating or installing LilyPond versions) is all you need to make sure that you always have the complete and newest set of alternative fonts available for use with LilyPond! I think this should really encourage anybody to experiment with and use this newly available stylistic variety in music engraving.

So far I haven’t prepared an official “binary” release or included it into a Python repository, and I haven’t had the opportunity to incorporate this functionality in Frescobaldi (any help with this would be greatly appreciated). But you can download/clone/fork the tool from its repository on Github. Please visit that site for a more detailed description too.

Note: unfortunately I haven’t got any assistance yet to deal with this process on Windows too. So I assume that currently the program only works on Mac and Linux. If anyone has experience with handling symbolic links (or circumventing the need for that) on Windows with Python I’d be more than happy to accept help to make the tool available for all.

A New Library To Use Alternative Fonts

Now that we have the set of fonts available we also want to actually use them in scores. I’m pleased to tell you that this has become even more simple and powerful with the new interface provided by openLilyLib. Today I’ll only give you a short “teaser” about this, and in the next post I’ll go into more detail and present you the new functionality as well as differently styled engraving examples.

The original idea of setting up openLilyLib had been to have a place to store snippets of useful LilyPond code, similar to the official LilyPond Snippet Repository but not depending on a specific LilyPond version and having a Git interface for easier collaboration. Quite soon it was improved as to be includable – you can directly \include modules from openLilyLib instead of having to copy & paste code from the LSR and integrate that into your own files. But right now openLilyLib is undergoing a fundamental redesign, and the new Font Interface I’m presenting today is part of it. So you will see examples of the new way of using LilyPond extensions, but I won’t go into any detail about that new infrastructure as it is not ready for a general release and proper announcement (of course the readers of Scores of Beauty will be the first to know about any breaking news πŸ˜‰ ). All you have to know now is that in order to use the new font interface you need the latest version of openLilyLib and make its root directory and the ly directory inside available to LilyPond’s include path.

The following code, inserted at the top of the input file, will change the notation font to the Improviso font:

\include "openlilylib"
\useLibrary Stylesheets
\useNotationFont Improviso
Improviso default appearance (click to view PDF)

Improviso default appearance (click to view PDF)

  • The first line loads the general openLilyLib infrastructure, and I think putting this at the top of the input file will become a second nature for most, just as it is a no-brainer to start each file with a \version statement.
  • The second line loads the “Stylesheets” library – the new openLilyLib is organized around the concept of coherent libraries. The “Stylesheet” library so far only implements the font stuff but we plan to do much more with it in the not-too-distant future.
  • The last line finally switches the notation and the brace font to Improviso.

Maybe you noticed that the example doesn’t look like LilyPond’s default output with just the font replaced? Well, this is part of the additional horsepower I promised and that we’ll take a closer look at in the next post. So stay tuned …

Investigating installed fonts

So you know how easy it is to switch the notation font to one of the numerous alternatives that are available by now. But what if you just don’t have the list of installed fonts at your fingertips? Well, you might go to the font website to have a look, or you might investigate LilyPond’s font folder (if you know where this is). But fortunately openLilyLib provides a much more convenient way, and this is the last item for today’s post before I let you wait for the next post with more details and examples about the new fonts. As you may already guess the “Stylesheets” library provides a command for that purpose:

\include "openlilylib"
\useLibrary stylesheets

which will produce something similar to the following on the console:

Installed notation fonts:
- arnold
- beethoven
- cadence (no brace font)
- emmentaler
- gonville
- gutenberg1939
- haydn
- improviso
- lilyboulez (no brace font)
- lilyjazz
- paganini (no brace font)
- profondo
- ross
- scorlatti (no brace font)
- sebastiano

OK, next time we’ll see more examples and you’ll get the opportunity to taste some of the power that lies in the new infrastructure of openLilyLib. Controlling the wealth of new styles with a simple interface is just what makes life continuously easier with LilyPond. I always pointed out “programmability” as a unique advantage of text based systems. You may want to have a look at the underlying programming work that makes all this possible, so you can read the source code. The beauty of LilyPond is that such elaborate functionality can be made available for the “end user” with such elegant simplicity as \useNotationFont Improviso

23 thoughts on “Managing Alternative Fonts with LilyPond

    1. Urs Liska

      Well, it is a quite recent option, so it’s no wonder. With these posts – and with making it easier to use – I intend to make it more widely known. I think making this possible and creating such a range of fonts has been one of the more important LilyPond developments in recent years.

      1. Abraham Lee

        I wonder what else we can do to make this more visible than the whispered “Oh, and by the way, you can use different notation fonts now. Now let’s move on to …” kind of entry in the “Changes” page on Maybe some pictures? I just feel like it needs a little something more to catch the reader’s attention. It is kind of a big deal, if I do say so myself, amidst all the wonderful layout and coding updates that are showcased there. I know the entires on the “Changes” page are supposed to be minimal, but it seems a little TOO minimal.

        1. Urs Liska

          Yes, I think this should have a place in the Changes section for 2.20 vs. 2.18. A (minor) problem is that normally the example images are actuall LilyPond results (so the images are not stored but only the LilyPond code. This would require that the fonts are present on the machine that compiles the documentation (and so on every developer’s machines). This might be an issue as the fonts are and will of course remain optional.

          We can investigate if we can use precompiled images on the Changes page (thumbnails linked to PDF files).

  1. Abraham Lee

    Incredible work, what you’ve done, Urs! I’m glad we have this avenue to make this functionality known. I wonder if you’ve had any recent chances to discuss the new fonts or using custom fonts in general with any of the publishers you referred to. I’m sure more opportunities will come.

    1. Urs Liska

      Thank you very much. But having made this possible in the first place was incredible too, and the thing I’m building on top of. But I hope we’re not at the end of the line yet. If we manage to get the Stylesheets library in the direction we plan this will have an even more dramatic impact on LilyPond usability.

      I wll have this opportunity quite soon, and I’m very interested if the experiences and progress I’ve made over the last year will make a significant difference for convincing publishers …

  2. David Bellows

    Are we able to use the openlilylib method right now? I successfully installed all the new fonts using your python script and I can use those fonts in my test Lilypond files using the method at the top, but man, it would be so much cooler to use the openlilylib method. Is that something we can do now?

    Also, it took me a while to figure out what my “target” directory was for installing the fonts. I’m not sure if that’s something that can be made easier or even figured out by the software?

    In any case, congratulations on some really amazing work and thanks!

    1. Urs Liska

      Yes, it is perfectly possible to use the new openLilyLib functionality. When I wrote that it is not ready for a proper announcement/release I basically referred to two things: due to the very early stage it is quite possible that there will be more reorganizations or interface changes, so I wouldn’t want to encourage the use on a larger scale. However, it works well, and I already use it “in production”, you just have to expect to be required to change code once or more than once.

      The other thing that is missing is a proper documentation system. We have plans for providing auto-generated documentation, so that the library maintainers will document their source code, and a script will create complete documentation on a web site. This is also the main reason why there is only a quite small amount of functionality migrated to the new structure. We need something to design the infrastructure around, but this something should be quite small, so we don’t have to update too much code with each structural change. As soon as we’re clear about the structure of the documentation (not necessarily with the actual visible results, but with what we require from the modules) we’ll ask everybody who has contributed to openLilyLib to help us migrating the whole thing to the new structure.

      The steps to be taken are surely documented on openlilylib’s Github pages, but I can easily outline it here:

      Update openLilyLib to the latest state
      Ensure that its root directory and the “ly” directory inside are in LilyPond’s include path

      Then you should be able to use the code from the post.

      As for the usage of the font installation script: I don’t know how reliably it’s possible to automate the detection of the target directory/ies as LilyPond installations can be in so different places. Surely the documentation could be made more clear or more easily understandable. And I intend to integrate this with Frescobaldi where you’d be able to automatically “install” the fonts to all LilyPonds that are known to Frescobaldi.

  3. datahaki

    Thank you for providing these beautiful glyphs, Abraham! We are considering to use a selection of them, mostly noteheads and accidentals, in the graphics pipeline of our software.

    For assessment, we compiled a glyph comparison overview.

  4. Philippe Massart

    It’s really nice and easy πŸ™‚
    My main question is: how can I combine these easy commands and a paper block changing the text fonts? If I change the global text font using set-global-fonts or make-pango-font-tree in the paper block, I overwrite the music font change. Is there a way to combine both, or will I need to go the “old” way (specify all in the paper block)?

    1. Urs Liska

      You’re asking the right question, and the simple answer is: wait until the patch I’m currently preparing has made its way to LilyPond πŸ™‚

      I was aware of that limitation, and when I started to work on it I realized that this should not go into openLilyLib but directly into LilyPond. In the current state of development you can set a notation font without setting the text fonts and then you can add them afterwards through e.g. \setTextFont roman "Whatever font you want". There is one remaining obstacle with assigning fonts to the font tree, but the outcome should be that you can simply use \setNotationFont and \setTextFont commands as toplevel commands.

  5. Juan Pablo Bello

    hello! i have been Reading this blog for a year or more but have kept quiet about it until now. This work has been just too amazing to be true and it just Works. I will donate soon. I was able to do everything and have the fonts working and impressing my friends on the side πŸ˜‰ i also plan to update my graduate work on lilypond and its usage by and for the blind /visually impaired like myself with this change. My only concern is if there is any way of changing music fonts during the actual music? or if that is mentoined anywhere that i perhaps haven’t looked? my experience with producing certain outputs in lilypond has always been a bit like searching through a public marketplace (snipet repository, reference, internals, this blog, openlilylib…) sometimes that frustrates me to no end, but then again i in the end love that aproach too because music sometimes Works taht way. Keep it up. I am definitely a big fan and hopefully (shortly) supported of all your work.

  6. Alkan

    Urs, thanks so much for this functionality. I’m trying to run the script on OS X 10.10 but it doesn’t find a LilyPond installation no matter what I enter for the target:

    Alkans-MacBook-Pro:lily-fonts-master alkan$ python install-lily-fonts -d /Users/alkan/Documents/lilyfonts/fonts -t /Applications/

    Determined font directory:
    Error condition:
    No LilyPond installation found at or in
    Abort script.

    I’ve tried pointing to /Applications and /Applications/LilyPond, as well as the lilypond executable directly in the .app binary, as above. I’d be really grateful for any assistance.

  7. Pingback: Glyph comparison of alternative music fonts | Scores of Beauty

  8. Pingback: β€œArnold” | Scores of Beauty

  9. Juanca

    Hi, the page is broken, I downloaded and use the fonts the last year , and now I use Ubuntu 16.04 and the fonts dissapear πŸ™ and the detailed instructions of installation and usage (the last months don’t use lilypond for my baby’s birth)

    1. Abraham Lee

      Sorry. The down-ed site is my fault. I’m working very hard to get a new site up and running. I’m almost through most of the details, cleaning up files, scripts, samples, etc. There’s a lot more to consider than I originally thought. Thanks for your patience!


Leave a Reply

Your email address will not be published. Required fields are marked *