When using lilypond-book it’ll create separate eps/pdf files for each score embedded in the latex sources. Each one embeds a (possibly different) subsetting of the respective music fonts. The end result is that the same glyphs are contained many times and the PDF filesize is blown up dramatically.

Is there a workaround?

Attempt 1: Embed fonts later

I found -dgs-never-embed-fonts=true -dbackend=ps which causes the fonts to not be embedded at all. But I do need the fonts in the final PDF. I tried to use gs to embed and subset the fonts, but it fails to find them:

gs -dEmbedAllFonts=true -dPrinted=false -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH
Substituting font Helvetica for Emmentaler-18.
Substituting font Helvetica for TeXGyreSchola-Regular.

I’m not sure how I can tell gs where to look for the respective fonts (I can find the according woff, svg or otf files on my disk).

Attempt 2: Merge embedded fonts

I monkey-patched the lilypond script to disable font subsetting.

sed -i 's~NeverEmbed~SubsetFonts false /AlwaysEmbed~' /usr/share/lilypond/2.19.83/scm/framework-ps.scm

This works (together with -dgs-never-embed-fonts=true -dbackend=ps) and fonts are now always embedded without subsetting.

However, apparently there’s no easy way to merge them. I did try pdfsizeopt, but it bails out in this particular case with

warning: ignoring … Type1C fonts with /CharStrings longer than 256, obj nums are […]
  • Ghostscript keeps a list of known fonts and mappings in two files cidfmap and Fontmap, which on my system are found in /var/lib/ghostscript/fonts/. I'm not really sure how that works but presumably you can add fonts to that list, to be used with your Attempt 1. – Marijn Apr 15 at 11:23

Your Answer

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

Browse other questions tagged or ask your own question.