4.2.2 Properties found in interfaces

Suppose now that we wish to print the lyrics in italics. What form of \override command do we need to do this? We first look in the IR page listing ‘All layout objects’, as before, and look for an object that might control lyrics. We find LyricText, which looks right. Clicking on this shows the settable properties for lyric text. These include the font-series and font-size, but nothing that might give an italic shape. This is because the shape property is one that is common to all font objects, so, rather than including it in every layout object, it is grouped together with other similar common properties and placed in an Interface, the font-interface.

So now we need to learn how to find the properties of interfaces, and to discover what objects use these interface properties.

Look again at the IR page which describes LyricText. At the bottom of the page is a list of clickable interfaces which LyricText supports. The list has several items, including font-interface. Clicking on this brings up the properties associated with this interface, which are also properties of all the objects which support it, including LyricText.

Now we see all the user-settable properties which control fonts, including font-shape(symbol), where symbol can be set to upright, italics or caps.

You will notice that font-series and font-size are also listed there. This immediately raises the question: Why are the common font properties font-series and font-size listed under LyricText as well as under the interface font-interface but font-shape is not? The answer is that font-series and font-size are changed from their global default values when a LyricText object is created, but font-shape is not. The entries in LyricText then tell you the values for those two properties which apply to LyricText. Other objects which support font-interface will set these properties differently when they are created.

Let’s see if we can now construct the \override command to change the lyrics to italics. The object is LyricText, the property is font-shape and the value is italic. As before, we’ll omit the context.

As an aside, although it is an important one, note that because the values of font-shape are symbols they must be introduced with a single apostrophe, '. That is why apostrophes are needed before thickness in the earlier example and font-shape. These are both symbols too. Symbols are then read internally by LilyPond. Some of them are the names of properties, like thickness or font-shape, others are used as values that can be given to properties, like italic. Note the distinction from arbitrary text strings, which would appear as "a text string"; for more details about symbols and strings, see Scheme tutorial.

So we see that the \override command needed to print the lyrics in italics is:

\override LyricText #'font-shape = #'italic

This should be placed just in front of the lyrics we wish to affect, like so:

  \key es \major
  \time 6/8
    r4 bes8 bes[( g]) g |
    g8[( es]) es d[( f]) as |
    as8 g
  \addlyrics {
    \override LyricText #'font-shape = #'italic
    The man who | feels love's sweet e -- | mo -- tion

[image of music]

and the lyrics are all printed in italics.

Specifying the context in lyric mode

In the case of lyrics, if you try specifying the context in the format given earlier the command will fail. A syllable entered in lyricmode is terminated by either a space, a newline or a digit. All other characters are included as part of the syllable. For this reason a space or newline must appear before the terminating } to prevent it being included as part of the final syllable. Similarly, spaces must be inserted before and after the period or dot, ‘.’, separating the context name from the object name, as otherwise the two names are run together and the interpreter cannot recognize them. So the command should be:

\override Lyrics . LyricText #'font-shape = #'italic

Nota bene : In lyrics always leave whitespace between the final syllable and the terminating brace.

Nota bene : In overrides in lyrics always place spaces around the dot between the context name and the object name.

Zie ook

Extending: Scheme tutorial.

Andere talen: English, česky, deutsch, español, français, italiano, 日本語.
About automatic language selection.

LilyPond – Beginnershandleiding