4.3.2 Size of objects

Let us begin by looking again at the earlier example (see Nesting music expressions) which showed how to introduce a new temporary staff, as in an ossia.

\new Staff ="main" {
  \relative g' {
    r4 g8 g c4 c8 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff \with {
        alignAboveContext = #"main" }
      { f8 f c }
    >>
    r4 |
  }
}

[image of music]

Ossia are normally written without clef and time signature, and are usually printed slightly smaller than the main staff. We already know now how to remove the clef and time signature – we simply set the stencil of each to #f, as follows:

\new Staff ="main" {
  \relative g' {
    r4 g8 g c4 c8 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff \with {
        alignAboveContext = #"main"
      }
      {
        \omit Staff.Clef
        \omit Staff.TimeSignature
        { f8 f c }
      }
    >>
    r4 |
  }
}

[image of music]

where the extra pair of braces after the \with clause are required to ensure the enclosed overrides and music are applied to the ossia staff.

But what is the difference between modifying the staff context by using \with and modifying the stencils of the clef and the time signature with \override, or in this case \omit? The main difference is that changes made in a \with clause are made at the time the context is created, and remain in force as the default values for the duration of that context, whereas \set or \override commands embedded in the music are dynamic – they make changes synchronized with a particular point in the music. If changes are unset or reverted using \unset or \revert they return to their default values, which will be the ones set in the \with clause, or if none have been set there, the normal default values.

Some context properties can be modified only in \with clauses. These are those properties which cannot sensibly be changed after the context has been created. alignAboveContext and its partner, alignBelowContext, are two such properties – once the staff has been created its alignment is decided and it would make no sense to try to change it later.

The default values of layout object properties can also be set in \with clauses. Simply use the normal \override command leaving out the context name, since this is unambiguously defined as the context which the \with clause is modifying. If fact, an error will be generated if a context is specified in this location.

So we could replace the example above with

\new Staff ="main" {
  \relative g' {
    r4 g8 g c4 c8 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff \with {
        alignAboveContext = #"main"
        % Don't print clefs in this staff
        \override Clef.stencil = ##f
        % Don't print time signatures in this staff
        \override TimeSignature.stencil = ##f
      }
      { f8 f c }
    >>
    r4 |
  }
}

[image of music]

It turns out that we can also employ the shorthands \hide and \omit for setting the transparent property and clearing the stencil here, leading to the result

\new Staff ="main" {
  \relative g' {
    r4 g8 g c4 c8 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff \with {
        alignAboveContext = #"main"
        % Don't print clefs in this staff
        \omit Clef
        % Don't print time signatures in this staff
        \omit TimeSignature
      }
      { f8 f c }
    >>
    r4 |
  }
}

[image of music]

Finally we come to changing the size of layout objects.

Some layout objects are created as glyphs selected from a typeface font. These include note heads, accidentals, markup, clefs, time signatures, dynamics and lyrics. Their size is changed by modifying the font-size property, as we shall shortly see. Other layout objects such as slurs and ties – in general, spanner objects – are drawn individually, so there is no font-size associated with them. These objects generally derive their size from the objects to which they are attached, so usually there is no need to change their size manually. Still other properties such as the length of stems and bar lines, thickness of beams and other lines, and the separation of staff lines all need to be modified in special ways.

Returning to the ossia example, let us first change the font-size. We can do this in two ways. We can either change the size of the fonts of each object type, like NoteHeads with commands like

\override NoteHead.font-size = #-2

or we can change the size of all fonts by setting a special property, fontSize, using \set, or by including it in a \with clause (but without the \set).

\set fontSize = #-2

Both of these statements would cause the font size to be reduced by 2 steps from its previous value, where each step reduces or increases the size by approximately 12%.

Let’s try it in our ossia example:

\new Staff ="main" {
  \relative g' {
    r4 g8 g c4 c8 d |
    e4 r8
    <<
      { f8 c c }
      \new Staff \with {
        alignAboveContext = #"main"
        \omit Clef
        \omit TimeSignature
        % Reduce all font sizes by ~24%
        fontSize = #-2
      }
      { f8 f c }
    >>
    r4 |
  }
}

[image of music]

This is still not quite right. The note heads and flags are smaller, but the stems are too long in proportion and the staff lines are spaced too widely apart. These need to be scaled down in proportion to the font reduction. The next sub-section discusses how this is done.


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

LilyPond – Beginnershandleiding v2.17.97 (ontwikkelingstak).