]> git.donarmstrong.com Git - lilypond.git/blob - ps/lilyponddefs.ps
patch::: 1.4.0.jcn5
[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 /lilyponddedication known {
169                 normal-font lilyponddedication set-centered
170                 line-y 10 sub /line-y exch def
171         } if
172         currentdict /lilypondtitle known {
173                 huge-bold-font lilypondtitle set-centered
174                 line-y 5 sub /line-y exch def
175         } if
176         currentdict /lilypondsubtitle known {
177                 Large-bold-font lilypondsubtitle set-centered
178                 line-y 5 sub /line-y exch def
179         } if
180         currentdict /lilypondsubsubtitle known {
181                 large-bold-font lilypondsubsubtitle set-centered
182         } if
183         line-y /mini-page exch def
184         currentdict /lilypondcomposer known {
185                 large-smallcaps-font lilypondcomposer set-right
186                 line-y 2 sub /line-y exch def
187         } if
188         currentdict /lilypondopus known {
189                 normal-font lilypondopus set-right
190                 line-y 3 sub /line-y exch def
191         } if
192         currentdict /lilypondarranger known {
193                 normal-font lilypondarranger set-right
194                 line-y 3 sub /line-y exch def
195         } if
196         currentdict /lilypondpoet known {
197                 mini-page /line-y exch def
198                 normal-font lilypondpoet set-left
199                 line-y 3 sub /line-y exch def
200         } if
201         currentdict /lilypondtexttranslator known {
202                 normal-font lilypondtexttranslator set-left
203                 line-y 3 sub /line-y exch def
204         } if
205         currentdict /lilypondinstrument known {
206                 large-font lilypondinstrument set-centered
207         } if
208         currentdict /lilypondpiece known {
209                 large-smallcaps-font lilypondpiece set-left
210         } if
211 } bind def
212
213 /end-lilypond-output
214 {
215         /line-y top-margin def
216         footnote-font lilypondtagline set-left
217         showpage
218 } bind def
219
220 /turnOnExperimentalFeatures { } bind def
221
222 staff-line-thickness setlinewidth
223
224 % set postscript paper size
225 paper-size
226
227 % initialise paper dimensions
228 staff-height init-paper
229
230 /line-x left-margin def
231 /line-y vsize top-margin sub def
232
233 make-lilypond-title
234
235 % see if we're there...
236 % 10 setlinewidth 0 0 moveto 400 800 lineto stroke