Skip to content

SVG Adapting older templates

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

SVG: Adapting older templates

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.

If you have updated your templates during the installation of OLy 1.0.0 or later (with the "Restore templates" button) or this OLy version was the first you have ever installed, you can leave this page because there is nothing more to prepare.

If your templates come from an OLy version starting with 0.5 and you did not yet prepare the templates with an [SVG] in their name, here is some more work for you.

We now have to explicitely specify the font families*1. Therefore we need to go to the template folder (its location can be viewed in the OLy Config dialog) and manually edit the template files that have [SVG] in their name. Inside the paper{...} section, there is a paragraph that has been prepared for that purpose:

% If LilyPond's default fonts are not installed and therefore "invisible" to other applications,
% you can define a replacement font here:

%{
#(define fonts
   (make-pango-font-tree
    "TeXGyreSchola"           ; adjust this font name according to your needs
    "TeXGyreHeros"            ; adjust this font name according to your needs
    "TeXGyreCursor"           ; adjust this font name according to your needs
    (/ staff-height pt 20)))
%}

The command itself is enclosed in block comment signs %{ and %}. Putting a simple blank space between % and { will turn the first into an ordinary comment, and the code between them will become visible for LilyPond:

% {
#(define fonts
   (make-pango-font-tree
    "TeXGyreSchola"           ; adjust this font name according to your needs
    "TeXGyreHeros"            ; adjust this font name according to your needs
    "TeXGyreCursor"           ; adjust this font name according to your needs
    (/ staff-height pt 20)))
%}

Now save the template and repeat the procedure with the other [SVG] templates.

If your templates date from OLy 0.5.0 to 0.5.3, the paragraph will rather look like this:

% If LilyPond's default fonts are not installed and therefore "invisible" to other applications,
% you can define a replacement font here:

% {
% for LilyPond 2.19.11 and older, it only works like this:
#(define fonts
   (make-pango-font-tree
    "Century Schoolbook"  ; adjust this font name according to your system
    "sans-serif"
    "monospace"
    (/ staff-height pt 20)))
%}

In that case, just replace it by the code given above.

Phew! Now you should be able to use that SVG feature without further issues.


*1) Unfortunately, the LilyPond developers decided to make another change after V. 2.18: .svg graphic files created by LilyPond 2.19 no more contain font names by default. Instead, they use aliases like "serif", "sans-serif" and "monospace". While there might be some reasons for that decision, we are therefore required to make the adjustments described above.

To simplify this whole mess, as of version 1.0.0 OLy will assume that you have installed the necessary fonts as described in SVG formats: Providing fonts. All [SVG] and [SVG -dcrop] templates already contain the required declarations. (back)