| [ << Musical notation ] | [Top][Contents][Index] | [ Specialist notation >> ] |
| [ < Single entry fonts ] | [ Up : Fonts ] | [ Music fonts > ] |
Entire document fonts
It is possible to change the fonts used in LilyPond’s default font
families by calling the function make-pango-font-tree. The
arguments are substitutions for the ‘roman’, ‘sans’ and
‘typewriter’ font families (in that order), followed by a
scaling factor. Similar to single fonts (see Single entry fonts), font families are set up by using comma-separated lists
of font family names, but without style options.1
Note that make-pango-font-tree resets the notation fonts to
‘Emmentaler’ as the default.
The example below adjusts the font size in relation to the global staff size.
\paper { #(define fonts (make-pango-font-tree "Linux Libertine O" "Nimbus Sans, Nimbus Sans L" "DejaVu Sans Mono" (/ staff-height pt 20))) } \relative c'{ c1-\markup { roman, \sans sans, \typewriter typewriter. } }
LilyPond provides an alternative, more flexible interface to set
global font families. It allows you to change only specific font
family names, leaving others set to default values. The following
example has the same effect as the above
make-pango-font-tree example; the syntax for font family
names is identical. If you do not change the staff size from the
default of 20pt, the line containing the #:factor
keyword is unnecessary.
\paper {
#(define fonts
(set-global-fonts
#:roman "Linux Libertine O"
#:sans "Nimbus Sans, Nimbus Sans L"
#:typewriter "DejaVu Sans Mono"
; unnecessary if the staff size is default
#:factor (/ staff-height pt 20)
))
}
Additionally, set-global-fonts can also set the music
notation fonts. The following example has the same effect as the
previous examples, because it uses the default notation fonts.
For more information, see Replacing the notation font.
\paper {
#(define fonts
(set-global-fonts
#:music "emmentaler" ; default
#:brace "emmentaler" ; default
#:roman "Linux Libertine O"
#:sans "Nimbus Sans, Nimbus Sans L"
#:typewriter "DejaVu Sans Mono"
; unnecessary if the staff size is default
#:factor (/ staff-height pt 20)
))
}
Note that each call to set-global-fonts completely resets
both the main notation and text fonts.2 If
any font category is left unspecified, the respective default font
(family) gets used for that category. Each call of
set-global-fonts affects all \book blocks that
follow it. If there are multiple \book blocks and you want
to use different fonts for each, simply call
set-global-fonts again, like this:
\paper {
#(define fonts
(set-global-fonts
…
))
}
\book {
…
}
\paper {
#(define fonts
(set-global-fonts
…
))
}
\book {
…
}
See also
Notation Reference: Finding fonts, Font families, Single entry fonts, Selecting font and font size, Font markup, Replacing the notation font.
Footnotes
[1] This implies that, contrary to single fonts, a trailing comma is never necessary.
[2] To be more
precise, ‘emmentaler’ (with a lowercase ‘e’, which is
mandatory in the argument to #:music and #:brace) is
a set of fonts (but not a font family in the FontConfig sense)
that LilyPond accesses and manages directly. Instead of various
styles, however, it comes with different design sizes,
see Music fonts and Replacing the notation font. The
corresponding FontConfig font names are ‘Emmentaler-size’,
where size is one of the numbers 11, 13, 14, 16, 18, 20, 23,
and 26.
For braces, the FontConfig font name is ‘Emmentaler-Brace’.
| [ << Musical notation ] | [Top][Contents][Index] | [ Specialist notation >> ] |
| [ < Single entry fonts ] | [ Up : Fonts ] | [ Music fonts > ] |
![[image of music]](../f5/lily-8321a531.png)