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