lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can we change text font while keep it italic?


From: Aaron Hill
Subject: Re: Can we change text font while keep it italic?
Date: Tue, 29 Jan 2019 07:35:04 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-01-29 12:51 am, Fan Hongtao wrote:
User backend properties
<http://lilypond.org/doc/v2.18/Documentation/internals/user-backend-properties>
says:

font-name (string)
Specifies a file name (without extension) of the font to load. This
setting overrides
selection using font-family, font-series and font-shape.

So I try to reset these properties.

\version "2.18.2"
\markup {
  \override #'(font-name . "Century")
  \override #'(font-family . roman)
  \override #'(font-series . medium)
  \override #'(font-shape . italic)
  \italic { Hello, world. }
}

Unfortunately, it does not work. Any suggestion?

When you specify font-name, you are effectively telling LilyPond not to use font-family, font-series or font-shape. That is what the documentation means when it says that setting overrides font selection. Commands like \italic will have no effect once you have set a font-name. See the following:

%%%%
\version "2.19.82"

\markup {
  \override #'(font-name . "Roboto") "Regular"
  \override #'(font-name . "Roboto, Bold") "Bold"
  \override #'(font-name . "Roboto, Italic") "Italic"
}

\paper { #(define fonts (set-global-fonts #:sans "Roboto")) }
\markup \sans { "Regular" \bold "Bold" \italic "Italic" }
%%%%

The first case above uses the font-name to explicitly select a font. Note that you must include the style within the name. This option is useful for one-off fonts.

The second case above redefines one of the provided font families and, as such, will work with the markup commands like \italic. This option is best for most general use, as it ensure consistent font usage throughout a document.

LilyPond defines three font families for text: roman, sans, and typewriter. With a little bit of work, you technically can define your own family in addition to these:

%%%%
\version "2.19.82"

\paper {
  #(define fonts
    (let ((n (set-global-fonts))
          (factor (/ staff-height pt 20)))
      (add-pango-fonts n 'handwriting "Alex Brush" (* 1.5 factor))
      n))
}

#(define-markup-command (handwriting layout props arg) (markup?)
  (interpret-markup layout
    (prepend-alist-chain 'font-family 'handwriting props) arg))

\markup { This is \handwriting hand-written text. }
%%%%

-- Aaron Hill

Attachment: custom-font-family.cropped.png
Description: PNG image

Attachment: font-name.cropped.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]