]> git.donarmstrong.com Git - lilypond.git/blob - ps/lilyponddefs.ps
patch::: 1.3.149.jcn3
[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         } if
77         line-y top-margin sub base-line-skip lt {
78                 showpage
79                 /line-y vsize top-margin sub def
80         } if
81         gsave
82         line-x line-y translate
83 } bind def
84
85 /stop-line
86
87         /the-line exch def
88         the-line
89         stroke
90         grestore
91         line-y line-height output-scale mul sub /line-y exch def
92 } bind def
93
94 % FIXME: font definitions should come from LilyPond
95 %        built-in ps fonts are ugly
96 /huge-bold-font {
97         /Times-Bold findfont 20.7 scalefont setfont
98 } bind def
99
100 /Large-bold-font {
101         /Times-Bold findfont 17.3 scalefont setfont
102 } bind def
103
104 /large-bold-font {
105         /Times-Bold findfont 14.4 scalefont setfont
106 } bind def
107
108 /large-font {
109         /Times-Roman findfont 14.4 scalefont setfont
110 } bind def
111
112 /large-smallcaps-font {
113         % urg
114         /Helvetica findfont 14.4 scalefont setfont
115 } bind def
116
117 /normal-font {
118         /Times-Roman findfont 12 scalefont setfont
119 } bind def
120
121 /footnote-font {
122         /Times-Roman findfont 10 scalefont setfont
123 } bind def
124
125 /get-text-dimensions % path .. width height
126 {
127         dup true charpath pathbbox
128         newpath
129         line-x line-y moveto
130         exch 4 -1 roll
131         sub
132         3 1 roll
133         exch sub
134 } bind def
135
136 /set-centered
137 {
138         line-x line-y moveto
139         get-text-dimensions
140         neg line-y add /line-y exch def
141         neg line-width add 2 div 0 rmoveto
142         show
143 } bind def
144
145 /set-left
146 {
147         line-x line-y moveto
148         get-text-dimensions
149         neg line-y add /line-y exch def
150         pop
151         show
152 } bind def
153
154 /set-right
155 {
156         line-x line-y moveto
157         get-text-dimensions
158         neg line-y add /line-y exch def
159         neg line-width add 0 rmoveto
160         show
161 } bind def
162
163 /make-lilypond-title
164 {
165         currentdict /lilypondtitle known {
166                 huge-bold-font lilypondtitle set-centered
167                 line-y 5 sub /line-y exch def
168         } if
169         currentdict /lilypondsubtitle known {
170                 Large-bold-font lilypondsubtitle set-centered
171                 line-y 5 sub /line-y exch def
172         } if
173         currentdict /lilypondsubsubtitle known {
174                 large-bold-font lilypondsubsubtitle set-centered
175         } if
176         currentdict /lilypondcomposer known {
177                 large-smallcaps-font lilypondcomposer set-right
178         } if
179         currentdict /lilypondopus known {
180                 normal-font lilypondopus set-right
181         } if
182         currentdict /lilypondarranger known {
183                 normal-font lilypondarranger set-right
184         } if
185         currentdict /lilypondinstrument known {
186                 large-font lilypondinstrument set-centered
187         } if
188         currentdict /lilypondpiece known {
189                 large-smallcaps-font lilypondpiece set-left
190         } if
191 } bind def
192
193 /end-lilypond-output
194 {
195         /line-y top-margin def
196         footnote-font lilypondtagline set-left
197         showpage
198 } bind def
199
200 /turnOnExperimentalFeatures { } bind def
201
202 staff-line-thickness setlinewidth
203
204 % set postscript paper size
205 paper-size
206
207 % initialise paper dimensions
208 staff-height init-paper
209
210 /line-x left-margin def
211 /line-y vsize top-margin sub def
212
213 make-lilypond-title
214
215 % see if we're there...
216 % 10 setlinewidth 0 0 moveto 400 800 lineto stroke