]> git.donarmstrong.com Git - lilypond.git/blob - ps/lilyponddefs.ps
* scm/output-ps.scm (make-title, output-scopes): Further
[lilypond.git] / ps / lilyponddefs.ps
1 %!PS-Adobe-1.0: lilyponddefs.ps
2 %
3 % Functions for direct PostScript output
4
5 % hmm
6 % /setgray { 1 add } bind def
7
8 % To let gs load fonts from builddir, do:
9 % export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
10
11 /staff-line-thickness lilypondpaperlinethickness def
12 /staff-height lilypondpaperstaffheight def
13 /line-width lilypondpaperlinewidth def
14
15 % FIXME: why isn't this set (by default) by lily?
16 % /text-height lilypondpapertextheight def
17
18 /lily-output-units 2.83464  def  %% milimeter
19 % /lily-output-units 0.996264  def  %% true points.
20
21 /output-scale
22 lilypondpaperoutputscale lily-output-units mul 
23 def
24
25 /set-ps-scale-to-lily-scale
26 {
27 output-scale output-scale scale
28 } bind def
29
30 /paper-size { lilypondpaperpapersize } bind def
31
32 % FIXME
33 % urg, read from paper block
34 % fixed base line skip value, for single line staves
35 /base-line-skip lilypondpaperlineheight def
36
37 /init-paper {
38         gsave
39         .1 setlinewidth
40         clippath pathbbox newpath
41         /vsize exch def
42         /hsize exch def  pop pop pop
43
44         %FIXME:
45         %vsize text-height sub 2 div /top-margin exch def
46         144 2 div /top-margin exch def
47         hsize line-width sub 2 div /left-margin exch def
48         grestore
49 } bind def
50
51 /place-box
52 {
53         /object exch def
54         gsave
55         %exch translate
56         translate
57         0 0 moveto
58         object
59         grestore
60 } bind def
61
62 /start-system % height
63 {
64         dup base-line-skip gt {
65                 /line-height exch def
66         }
67         {
68                 pop /line-height base-line-skip def
69         } ifelse
70         line-y top-margin sub base-line-skip lt {
71                 showpage
72                 /line-y vsize top-margin sub def
73         } if
74         gsave
75         line-x line-y translate
76 } bind def
77
78 /stop-system
79
80         /the-line exch def
81         the-line
82         stroke
83         grestore
84         line-y line-height output-scale mul sub /line-y exch def
85 } bind def
86
87 % FIXME: font definitions should come from LilyPond
88 %        built-in ps fonts are ugly
89 /huge-bold-font {
90         /Palatino-Bold findfont 20.7 scalefont setfont
91 } bind def
92
93 /Large-bold-font {
94         /Palatino-Bold findfont 17.3 scalefont setfont
95 } bind def
96
97 /large-bold-font {
98         /Palatino-Bold findfont 14.4 scalefont setfont
99 } bind def
100
101 /large-font {
102         /Palatino-Roman findfont 14.4 scalefont setfont
103 } bind def
104
105 /large-smallcaps-font {
106         % urg
107         /Bookman-Light findfont 14.4 scalefont setfont
108 } bind def
109
110 /normal-font {
111         /Palatino-Roman findfont 12 scalefont setfont
112 } bind def
113
114 /footnote-font {
115         /Palatino-Roman findfont 10 scalefont setfont
116 } bind def
117
118 /get-text-dimensions % path .. width height
119 {
120         dup true charpath pathbbox
121         newpath
122         line-x line-y moveto
123         exch 4 -1 roll
124         sub
125         3 1 roll
126         exch sub
127 } bind def
128
129 /set-centered
130 {
131         line-x line-y moveto
132         get-text-dimensions
133         neg line-y add /line-y exch def
134         neg line-width add 2 div 0 rmoveto
135         show
136 } bind def
137
138 /set-left
139 {
140         line-x line-y moveto
141         get-text-dimensions
142         neg line-y add /line-y exch def
143         pop
144         show
145 } bind def
146
147 /set-right
148 {
149         line-x line-y moveto
150         get-text-dimensions
151         neg line-y add /line-y exch def
152         neg line-width add 0 rmoveto
153         show
154 } bind def
155
156 /make-lilypond-title
157 {
158         currentdict /lilyponddedication known {
159                 normal-font lilyponddedication set-centered
160                 line-y 10 sub /line-y exch def
161         } if
162         currentdict /lilypondtitle known {
163                 huge-bold-font lilypondtitle set-centered
164                 line-y 5 sub /line-y exch def
165         } if
166         currentdict /lilypondsubtitle known {
167                 Large-bold-font lilypondsubtitle set-centered
168                 line-y 5 sub /line-y exch def
169         } if
170         currentdict /lilypondsubsubtitle known {
171                 large-bold-font lilypondsubsubtitle set-centered
172         } if
173         line-y /mini-page exch def
174         currentdict /lilypondcomposer known {
175                 large-smallcaps-font lilypondcomposer set-right
176                 line-y 2 sub /line-y exch def
177         } if
178         currentdict /lilypondopus known {
179                 normal-font lilypondopus set-right
180                 line-y 3 sub /line-y exch def
181         } if
182         currentdict /lilypondarranger known {
183                 normal-font lilypondarranger set-right
184                 line-y 3 sub /line-y exch def
185         } if
186         currentdict /lilypondpoet known {
187                 mini-page /line-y exch def
188                 normal-font lilypondpoet set-left
189                 line-y 3 sub /line-y exch def
190         } if
191         currentdict /lilypondtexttranslator known {
192                 normal-font lilypondtexttranslator set-left
193                 line-y 3 sub /line-y exch def
194         } if
195         currentdict /lilypondinstrument known {
196                 large-font lilypondinstrument set-centered
197         } if
198         currentdict /lilypondpiece known {
199                 large-smallcaps-font lilypondpiece set-left
200         } if
201 } bind def
202
203 /end-lilypond-output
204 {
205         /line-y top-margin def
206         footnote-font lilypondtagline set-left
207         showpage
208 } bind def
209
210 /turnOnExperimentalFeatures { } bind def
211
212 staff-line-thickness setlinewidth
213
214 % set postscript paper size
215 paper-size
216
217 % initialise paper dimensions
218 staff-height init-paper
219
220 /line-x left-margin output-scale div def
221 /line-y vsize top-margin sub def
222
223 % FIXME: testing \markup titles
224 % make-lilypond-title
225
226 % see if we're there...
227 % 10 setlinewidth 0 0 moveto 400 800 lineto stroke
228
229 % end lilyponddefs.ps