Duplicate fonts in pdf when using lilypond-book

by rumpel   Last Updated April 15, 2019 11:23 AM - source

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 […]


Related Questions


Installing Baskerville font for Lilypond in Ubuntu

Updated December 17, 2017 16:23 PM


Multiple embedded fonts in final PDF

Updated May 19, 2016 07:51 AM

Merging duplicate embedded fonts

Updated August 19, 2016 08:09 AM