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