Jump to content

Changing the default text font family: Difference between revisions

From LilyPond wiki
m New category
Tags: Mobile edit Mobile web edit
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The default font families for text can be overridden with <code>make-pango-font-tree</code>.
Here is how to override the default font families for text.


<lilypond version="2.24">
<div class="nodoc">
Note: Starting with LilyPond 2.25.4, font selection works differently; the most usual cases can be handled by {{Convert-ly-stable}}.  See the [{{LILYSTABLEDOC}}/notation/fonts ‘Notation’ manual] for more information.
</div>
 
<lilypond version="2.26">
%{
%{
You may have to install additional fonts.
You may have to install additional fonts.


Red Hat Fedora
Red Hat Fedora: dejavu-fonts-all
 
  dejavu-fonts-all
 
Debian GNU/Linux, Ubuntu


  fonts-dejavu-core
Debian GNU/Linux, Ubuntu: fonts-dejavu-core
  fonts-dejavu-extra
                          fonts-dejavu-extra
%}
%}


\paper {
\paper {
   % change for other default global staff size.
   property-defaults.fonts.serif = "DejaVu Serif"
  myStaffSize = #20
  property-defaults.fonts.sans = "DejaVu Sans"
  %{
  property-defaults.fonts.typewriter = "DejaVu Sans Mono"
    run
        lilypond -dshow-available-fonts
    to show all fonts available in the process log.
  %}
 
  #(define fonts
    (make-pango-font-tree "DejaVu Serif"
                          "DejaVu Sans"
                          "DejaVu Sans Mono"
    (/ myStaffSize 20)))
}
}


Line 38: Line 28:
   }
   }
   g4_\markup {
   g4_\markup {
     \override #'(font-family . sans) {
     \sans {
       DejaVu Sans: \bold bold
       DejaVu Sans: \bold bold
                   \italic italic
                   \italic italic
Line 45: Line 35:
   }
   }
   g''2^\markup {
   g''2^\markup {
     \override #'(font-family . typewriter) {
     \typewriter {
       DejaVu Sans Mono: \bold bold
       DejaVu Sans Mono: \bold bold
                         \italic italic
                         \italic italic
Line 54: Line 44:
</lilypond>
</lilypond>


[[Category:Text]]
[[Category:Text]]
[[Category:Text]]
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Included in the official documentation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]
[[Category:Snippet]]

Latest revision as of 04:36, 6 August 2026

Here is how to override the default font families for text.

Note: Starting with LilyPond 2.25.4, font selection works differently; the most usual cases can be handled by convert-ly. See the ‘Notation’ manual for more information.

\version "2.26"

%{
You may have to install additional fonts.

Red Hat Fedora: dejavu-fonts-all

Debian GNU/Linux, Ubuntu: fonts-dejavu-core
                          fonts-dejavu-extra
%}

\paper {
  property-defaults.fonts.serif = "DejaVu Serif"
  property-defaults.fonts.sans = "DejaVu Sans"
  property-defaults.fonts.typewriter = "DejaVu Sans Mono"
}

{
  g'''4^\markup {
    DejaVu Serif: \bold bold
                  \italic italic
                  \italic \bold { bold italic }
  }
  g4_\markup {
    \sans {
      DejaVu Sans: \bold bold
                   \italic italic
                   \italic \bold { bold italic }
    }
  }
  g''2^\markup {
    \typewriter {
      DejaVu Sans Mono: \bold bold
                        \italic italic
                        \italic \bold { bold italic }
    }
  }
}