Skip to content

SVG formats Providing fonts

Klaus Blum edited this page Apr 3, 2022 · 4 revisions

SVG formats: Providing fonts

ANNOUNCEMENT
OOoLilyPond has moved to a new repository:
https://github.com/OOoLilyPond
All past/present/future development can be found at the new location. The page you are viewing right here contains all development up to V. 1.0.1, but it will no longer be maintained.

When using the svg or svg [-dcrop] format instead of the png format, it could happen to you that LilyPond's default text fonts appear to be replaced by different fonts*1:

OLy02-Fonts-01

To prevent that unwanted replacement, you need to have installed those three font families (each of them as regular, bold, italic and bold italic version):

  • TeXGyreSchola
  • TeXGyreHeros
  • TeXGyreCursor

Please check if they are already available on your system. Probably they are not, so you will now have to install them manually:

If your LilyPond version starts with 2.19, you can already find necessary files on your computer. If you have LilyPond 2.18.2 or older, you can download those files from the web.

In either case, you now have twelve files matching the pattern texgyre*.otf. Those files now have to be installed by you. Usually, right-clicking on a *.otf file should bring up a context menu that contains an appropriate command, whether on Windows, Linux or Mac.

After that font installation procedure, you are now ready to use the svg [-dcrop] file format.


Appendix

This footnote gives some background information about that font problem. You won't miss anything important if you stop reading here.

;-)

*1) For the above picture, a simple {c1^"What does this look like?"} has been first rendered as .png image, second as .svg.

Now what has happened here?

In most cases, LilyPond is used to create .pdf files. Any font that is used will be embedded in the .pdf document. That means, it is displayed correctly, no matter if the font is installed on the target system or not. This is not the case when creating .svg files: Having them displayed as intended requires to have the fonts installed on the system.

The thing is, even on your computer, LilyPond can use its own fonts without them being installed, so probably they are not.

Which font files is LilyPond looking for? That depends on your LilyPond version.

Version 2.18.2 and earlier

According to the 2.18 Notation Reference, the roman (serif) font defaults to "New Century Schoolbook". Well, to be exact, it's the four files CenturySchL-Bold.otf, CenturySchL-BoldItal.otf, CenturySchL-Ital.otf and CenturySchL-Roma.otf which will show up as "Century Schoolbook L" font family.

Installing those four font files on your system might do the trick. On Linux (Ubuntu Studio 16.04) it worked well for me, but on Windows 7 only the bold and italic version were available to the system. So there must be a better solution.

In addition, the 2.18 Notation Reference tells that there are no default fonts for sans and typewriter, so different computers will produce different output.

Version 2.19

In the 2.19 Notation Reference you can see that LilyPond now provides fonts for all three font families: roman, sans and typewriter now default to "TeXGyreSchola", "TeXGyreHeros" and "TeXGyreCursor".

These are the fonts you are requested to install, see above. They work with old and new LilyPond versions. (back)