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