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_glyphsWhy 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
\NeedsTeXFormat{LaTeX2e} \documentclass[10pt]{letter} \usepackage{geometry} \geometry{a4paper,noheadfoot,nomarginpar,left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.5cm} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \usepackage{polyglossia} \setdefaultlanguage[spelling=old]{german} \setmainfont{CMU Serif} \setsansfont{CMU Sans Serif} \setmonofont{CMU Typewriter Text} \usepackage{graphicx} \def\tmpNameFull{tmplily.ly} \newwrite\tmpFileFull \def\tmpNameHead{tmplilyhead.ly} \newwrite\tmpFileHead \def\tmpNameTail{tmplilytail.ly} \newwrite\tmpFileTail \def\tmpNamePaper{tmplilypaper.ly} \newwrite\tmpFilePaper \def\tmpNamePdf{tmplily.pdf } \def\tmpfragprefix{tmplilyfrag} \def\lilycommand{/home/knut/fast/lilypond_2.18.2/bin/lilypond } \newcount\fragcount { \catcode`|=0 \catcode`[=1 \catcode`]=2 \catcode`\#=12 \catcode`\{=12 \catcode`\}=12 \catcode`\\=12 |gdef|eofull[\end{lilyfull}] |gdef|eohead[\end{lilyhead}] |gdef|eofrag[\end{lilyfrag}] |gdef|eotail[\end{lilytail}] |gdef|hashtag[#] |gdef|escape[\] |gdef|definepaper[\definepaper] ] { \obeylines \gdef\doline#1 { \def\oneline{#1} \ifx\oneline\eofull \def\next{\end{lilyfull}} \else \ifx\oneline\eohead \def\next{\end{lilyhead}} \else \ifx\oneline\eofrag \def\next{\end{lilyfrag}} \else \ifx\oneline\eotail \def\next{\end{lilytail}} \else \ifx\oneline\definepaper \immediate\write\tmpFile{\escape include "\tmpNamePaper"} \let\next\doline \else \immediate\write\tmpFile{\oneline} \let\next\doline \fi \fi \fi \fi \fi \next% } } \makeatletter \newenvironment{lilyfull}[2]{ \global\advance\fragcount by 1 \immediate\openout\tmpFileFull=\tmpNameFull \gdef\tmpFile{\tmpFileFull} \immediate\openout\tmpFilePaper=\tmpNamePaper \immediate\write\tmpFilePaper{\hashtag(set! paper-alist (cons '("mySize" . (cons (* #1) (* #2))) paper-alist))} \immediate\closeout\tmpFilePaper \let\do=\@makeother\dospecials\obeylines\doline }{ \immediate\closeout\tmpFileFull \immediate\write18{\lilycommand \tmpNameFull} \immediate\write18{pdfcrop \tmpNamePdf \tmpfragprefix\the\fragcount.pdf} \begin{center}\includegraphics{\tmpfragprefix\the\fragcount.pdf}\end{center} } \newenvironment{lilyfrag}[2]{ \global\advance\fragcount by 1 \immediate\openout\tmpFileFull=\tmpNameFull \gdef\tmpFile{\tmpFileFull} \immediate\write\tmpFileFull{\escape include "\tmpNameHead"} \immediate\openout\tmpFilePaper=\tmpNamePaper \immediate\write\tmpFilePaper{\hashtag(set! paper-alist (cons '("mySize" . (cons (* #1) (* #2))) paper-alist))} \immediate\closeout\tmpFilePaper \let\do=\@makeother\dospecials\obeylines\doline }{ \immediate\write\tmpFileFull{\escape include "\tmpNameTail"} \immediate\closeout\tmpFileFull % Uncomment to generate postscriptt files for debugging % \immediate\write18{\lilycommand --ps \tmpNameFull} % \immediate\write18{cp tmplily.ps \tmpfragprefix\the\fragcount.ps} \immediate\write18{\lilycommand \tmpNameFull} \immediate\write18{pdfcrop \tmpNamePdf \tmpfragprefix\the\fragcount.pdf} \begin{center}\includegraphics{\tmpfragprefix\the\fragcount.pdf}\end{center} } \newenvironment{lilyhead}{ \immediate\openout\tmpFileHead=\tmpNameHead \gdef\tmpFile{\tmpFileHead} \let\do=\@makeother\dospecials\obeylines\doline }{ \immediate\closeout\tmpFileHead } \newenvironment{lilytail}{ \immediate\openout\tmpFileTail=\tmpNameTail \gdef\tmpFile{\tmpFileTail} \let\do=\@makeother\dospecials\obeylines\doline }{ \immediate\closeout\tmpFileTail } \makeatother \def\lorem{ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. } \begin{document} \pagestyle{empty} \begin{lilyhead} \version "2.18.2" \include "deutsch.ly" \definepaper \paper { #(set-paper-size "mySize") left-margin = 0\cm top-margin = 0\cm bottom-margin = 0\cm line-width = \paper-width indent = 0 page-count = #1 ragged-right=##t ragged-bottom = ##t ragged-last-bottom = ##t annotate-spacing=##f } \header { tagline = ##f } #(set-global-staff-size 17) allowGrobCallback = #(define-scheme-function (parser location syms) (symbol-list?) (let ((interface (car syms)) (sym (cadr syms))) #{ \with { \consists #(lambda (context) `((acknowledgers . ((,interface . ,(lambda (engraver grob source-engraver) (let ((prop (ly:grob-property grob sym))) (if (procedure? prop) (ly:grob-set-property! grob sym (prop grob))))))))))}#})) absFontSize = #(define-scheme-function (parser location pt)(number?) (lambda (grob) (let* ((layout (ly:grob-layout grob)) (ref-size (ly:output-def-lookup (ly:grob-layout grob) 'text-font-size 12))) (magnification->font-size (/ pt ref-size))))) \score { << \end{lilyhead} \begin{lilytail} >> \layout { \context { \Score \allowGrobCallback font-interface.font-size \omit BarNumber } \override Lyrics.LyricText #'font-name = #"CMU Serif" \override LyricText.font-size = \absFontSize #10 \override StanzaNumber.font-name = #"CMU Serif Extra" \override StanzaNumber.font-size = \absFontSize #10 \override StanzaNumber.font-name = #"CMU Serif" \override StanzaNumber.font-size = \absFontSize #10 } } \end{lilytail} \lorem \begin{lilyfrag}{15 cm}{5 cm} \relative c'{\key c \major \time 4/4 \partial 8 c8 fis g4. ~ g4. c,8 \tuplet 3/2 {fis4 g a} \tuplet 3/2 {fis g a} fis8 g4. ~ g4.} \addlyrics { Ma -- ri -- a, __ I've just met a girl named Ma -- ri a, __} \end{lilyfrag} \lorem \begin{lilyfrag}{15 cm}{5 cm} \relative c'{\key c \major \time 6/8 \autoBeamOff \partial 8 c8 a'4 a8 a [g] a b4 (g8) e4} \addlyrics { In ei -- nem küh -- len Grun -- de, } \end{lilyfrag} \lorem \begin{lilyfrag}{15 cm}{5 cm} \relative c'{\key c \major \time 4/4 c2 b'2 a4. f8 d2} \addlyrics { There's a place for us } \end{lilyfrag} \lorem \begin{lilyfrag}{15 cm}{5 cm} \relative c'{\key c \major \time 4/4 c2 c'2 h4 g8 a h4 c} \addlyrics { Some -- where o -- ver the rain -- bow } \end{lilyfrag} \lorem \end{document}
tmp.pdf
Description: Adobe PDF document
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user