[luatex] pdf inclusion: extended font handling

Knut Petersen Knut_Petersen at t-online.de
Tue Dec 18 23:49:18 CET 2018

Hi everybody!

I often write documents that mix text and music, a short example is given below:

    {\bfseries O du fröhliche}\hspace{\fill}EG 44, 1-3\par
       \include "deutsch.ly"
         \relative a' {
           \key d \major
           a2 h a4. g8 fis4 (g) \breathe a2 h a4. g8 fis4 (g) \breathe \break
           a2 2 h cis4 d cis2 h a1
         \addlyrics {
           O du fröh -- li -- che, __ o du se -- li -- ge, __
           gna -- den -- brin -- gen -- de Weih -- nachts -- zeit!

The example above is intended to be translated with lualatex --shell-escape.

lyinla.sty provides the necessary code for the lilyfrag environement.
The text inside of a lilyfrag environment is extended and passed to the lilypond
music engraver. The result is a number of pdfs without any embedded
fonts, these pdf are included using \includegraphics. At the end of the lualatex
run (triggered by the stop_run callback) ghostscript is used to postprocess
the pdf generated by lualatex. A bit if postscript code provides the fonts to
ghostscript, the result is a final pdf that contains only one copy of every font
used in all the included pdfs, not one copy per usage of \includegraphics.

Often the mechanism pointed out above reduces file size by more than 80 percent.

Unfortunately recent changes to ghostscript (commit 04a517f39cc) broke
that mechanism, and it's not the first time that changes to gs broke my code.
I'd prefer to have a lualatex (or pdflatex/xelatex) that would be able to detect
usage of unembedded normal and CID fonts in included pdfs and to embed
exactly one subsetted copy of all needed fonts in the output pdf.

Is there already a solution somewhere in the bit bucket?

If not: Do you think it is possible to extend lua/xe/pdflatex with reasonable effort?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20181218/9a08a401/attachment.html>

More information about the luatex mailing list