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