lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: size of pdf files


From: Knut Petersen
Subject: Re: size of pdf files
Date: Fri, 05 Dec 2014 16:13:48 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 05.12.2014 00:25, Werner LEMBERG wrote:
How can I force lilypond to include the full emmentaler-design-size
font instead of only a subset?
LilyPond itself only produces PS files, *always* embedding complete
fonts, AFAIK.  Thus ghostscript's `-dSubsetFonts=false' option should
work for Emmentaler also.  Have you actually checked that by looking
into the various snippet PDF files produced by lilypond?

Yes, I verified that the Emmentaler-* fonts in lilypond pdfs are only subsets.
Thanks for pointing out that the postscript files contain the full fonts.

I compiled the attached lualatex document, it contains four short lilypond snippets
that are written to tmp files and compiled by lilypond (I used v2.18.2) on the fly. (You´ll
have to change the definition in line 22 to contain the correct path to your lilypond
executable if you try to luatex the file)

  lualatex --shell-escape lilyinluatex
  gs -dNOPAUSE -q -dBATCH -sOutputFile=tmp.pdf -sDEVICE=pdfwrite lilyinluatex.pdf

After that dir showed:

  -rw-rw-rw- 1 knut users  171192  5. Dez 14:58 lilyinluatex.pdf
  -rw-r--r-- 1 knut users  154502  5. Dez 14:58 tmp.pdf

Only a minor reduction of the file size.

Now I thought a bit and added "-dSubsetFonts=false" to the gs parameter list in
backend-library.scm. I also changed lilyponddefs.ps to include white-on-white print
commands for all the emmentaler glyphs used in the four examples (hint: grep, sed,
sort & uniq make it easy to get a list of glyphs from ps files):

/set-ps-scale-to-lily-scale {
    lily-output-units output-scale mul dup scale
    gsave
    1 setgray
    0 0 moveto magfontemmentaler-18mPYo /clefs.G glyphshow
    0 0 moveto magfontemmentaler-18mPYo /timesig.C44 glyphshow
    0 0 moveto magfontemmentaler-18mPYo /noteheads.s1 glyphshow
    0 0 moveto magfontemmentaler-18mPYo /noteheads.s2 glyphshow
    0 0 moveto magfontemmentaler-18mPYo /flags.u3 glyphshow
    0 0 moveto magfontemmentaler-18mPYo /dots.dot glyphshow
    0 0 moveto magfontemmentaler-18mPYo /accidentals.sharp glyphshow
    0 0 moveto magfontemmentaler-18mPYo /six glyphshow
    0 0 moveto magfontemmentaler-18mPYo /eight glyphshow
    0 0 moveto magfontemmentaler-18mPYo /accidentals.flat glyphshow
    grestore
} bind def

I executed

  lualatex --shell-escape lilyinluatex
  gs -dNOPAUSE -q -dBATCH -sOutputFile=tmp.pdf -sDEVICE=pdfwrite lilyinluatex.pd

and had a look at the directory:

  -rw-rw-rw- 1 knut users  290232  5. Dez 15:08 lilyinluatex.pdf
  -rw-r--r-- 1 knut users   61247  5. Dez 15:08 tmp.pdf

Ok. A file size reduction to about 36% of the original is a promising  result.

I think it would be a good idea to have some kind of interface to define
a set of emmentaler glyphs to be included in the pdfs and to allow
to activate the -dSubsetFonts=false setting in ghostscript.

There's some more room for improvements - as you can see, the example code
does not contain anything that should pull in the Schoolbook Roman font, but in the
postscript file I see
%%Page: 1 1
%%BeginPageSetup
%%EndPageSetup

gsave 0 paper-height translate set-ps-scale-to-lily-scale
0.0000 0.0000 moveto /CenturySchL-Roma 3.28515625 output-scale div selectfont
0.6025 0.0000 0.0000 /space
1 print_glyphs

 
Why does lilypond think it is a good idea to print a space at origin using an otherwise
unused font?

Currently I have no idea how to tell luatex and lilypond to use the Computer Modern
fonts in a way that allows ghostscript to eliminate one of the two remaining subsets.

The file notation.pdf of 2.18.2 contains more than 3400 font
subsets, more than 2000 are subsets of emmentaler-*.otf.  Most of
those could be eliminated, saving serval MB of filesize.
The question is whether pdftex is capable to do that – this program
processes the texinfo documentation, loads all the snippet PDF files,
ten doing the subsetting, and I guess it is not able to optimize this
on a global, document-wide level.

Not pdftex, ghostscript would be capable of doing that ...

May it works to disable subsetting in pdftex, cf.

  http://tex.stackexchange.com/questions/24002/turning-off-font-subsetting-in-pdftex

Interesting link, but the problem are the pdfs generated by lilypond via gs. I switched from
pdftex to luatex as it allows to use non-latin characters in csnames.

Then a call to gs for PDF->PDF processing might produce smaller output
files (or maybe there exist special tools to do that).

I don't see a better tool than ghostscript, at least nothing free and open source.
cu,
 Knut

Attachment: lilyinluatex.tex
Description: Text Data

Attachment: tmp.pdf
Description: Adobe PDF document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]