I am using LaTeX (pdflatex) and Lilypond together for a critical music edition, using the EB Garamond typeface for both. The two programs are giving me different glyphs for "Q": LaTeX provides a regular Q and Lilypond provides a swashy Q. I want the regular Q in both documents. Compare the results of the MWEs below.

The font provided by the ebgaramond package provides a swashy Q ligature. The ligature is not enabled by default in the version of the font loaded by pdflatex with T1 encoding. It is, apparently, enabled by default in the version of the font that Lilypond loads via pango. Lilypond's font loading is dependent on the system, and mine is Debian GNU/Linux v8 with Gnome v3.14.1.

Another question here (A Big fancy "Q") shows how to get the swashy Q in LaTeX (using lualatex and loading the font with the "Contextuals=Alternate" option). But I like the default pdflatex output and I don't want the swashy Q in Lilypond!

How can I get Lilypond to load the font file without the swashy Q ligature?

Why this is on topic: Lilypond is loading a font provided by a LaTeX package, ebgaramond, but it is loading it in a different way than the way LaTeX loads it. Thus this is about the interaction of Lilypond with a LaTeX package, though not necessarily with LaTeX itself.


File texquack.tex -- compile with pdflatex:


File lyquack.ly -- compile with lilypond:

\version "2.18.2"
\header {
  title = "Quack"
  tagline = ##f
\paper {
  #(define fonts
      "EB Garamond" "" ""
    (/ staff-height pt 20)))
\score {
    \new Staff
      \new Voice { a'1 }
      \new Lyrics \lyricmode { Quack }

LaTeX output: enter image description here Lilypond output: enter image description here

  • 2
    In my opinion, the swashy Q is nicer…
    – Bernard
    Jul 12 '16 at 20:48
  • I just compiled this on my system (OS X) with a newly downloaded copy of EB Garamond in my /Library/Fonts folder and I get the regular Q. This shows that LilyPond is using the system version of the font not the TeX version of the font. So maybe update your font?
    – Alan Munn
    Jul 12 '16 at 20:58
  • @AlanMunn I only have the LaTeX font in /usr/local/texlive/2016/texmf-dist/fonts/opentype/public/ebgaramond; the system is configured (via .fonts.conf) to use the LaTeX fonts. Jul 12 '16 at 21:45
  • 1
    Hmm. The problem is weirder than that. The two fonts have almost identical version numbers, so it's not the font, it's the engine. Compiling with LuaLaTeX yields the regular Q but the same document with XeLaTeX yields the swashed Q.
    – Alan Munn
    Jul 13 '16 at 3:30
  • 1
    Not that I know of. The LilyPond developers are clearly working on ways to manipulate font features in LilyPond though: lilypond.1069038.n5.nabble.com/OpenType-Features-td186089.html (I now think this question should be closed as off topic.)
    – Alan Munn
    Jul 13 '16 at 15:00

TeXLive 2016 provides the file EBGaramond12-Regular.otf as part of the ebgaramond package.

Inspecting via fontforge, I can see that this file defines the calt "Contextual Alternatives" font feature, in which the glyph Q is replaced by the glyph Q.long in certain contexts. These are defined in the table 'calt' Contextual Alternates Lookup 95 under Contextual 0 and Contextual 1. The substitution is defined in Single Substitution Lookup Table 96 and 97.

On my Debian system, the system automatically loads the font with the calt feature turned on. This is why the word Quack renders with the Q.long in any program using the system font selection mechanism. It is the same in LibreOffice as in Lilypond.

XeTeX loads the calt feature by default, but LuaTeX does not. Perhaps this is because XeTeX uses the system font mechanisms, while LuaTeX uses its own (luaotfload).

Consider these examples, for plain XeTeX and LuaTeX. We have to add the calt feature to LuaTeX (:+calt in the font definition) to get the swashy Q. Alternately we can remove the feature in XeTeX to get the regular Q (:-calt in the font definition).

XeTeX (compile with xetex):

\font\ebg="EB Garamond" \ebg Quack \bye

LuaTeX (compile with 'luatex'):

\input luaotfload.sty \font\ebg="EB Garamond:+calt" \ebg Quack \bye

The swashy Q is not available when using pdflatex because the program is not loading the OpenType font at all, but rather LaTeX font metric files (etc.) that have been adapted from the OpenType font, and the long Q is apparently not included.

As @AlanMunn notes, Lilypond developers are discussing how to improve Lilypond's font selection mechanisms, including specifying OpenType font features. This is not available in the stable version 2.18.2.

TL;DR -- Possible solutions are as follows:

  1. Embrace the swashy Q, and abandon pdflatex. Compile LaTeX portion with xelatex using fontspec defaults, or with lualatex selecting the calt feature through fontspec. The alternate contextuals also give a swashy italic Q and a lovely italic es ligature.
  2. Edit the font file to change the default features (e.g., edit the lookup tables in FontForge). Possibly could be done by writing a .fea file, as mentioned in the fontspec documentation.
  3. Accept variable Qs in the document. Since one is in a musical score and the other is in text, it is not as noticeable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.