]> git.donarmstrong.com Git - lilypond.git/blob - ps/lilyponddefs.ps
* lily/font-select.cc (properties_to_font_size_family): Fix
[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 % To let gs load fonts from builddir, do:
9 % export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
10
11 /staff-line-thickness lilypondpaperlinethickness def
12 /staff-height lilypondpaperstaffheight def
13 /line-width lilypondpaperlinewidth def
14
15 % FIXME: why isn't this set (by default) by lily?
16 % /text-height lilypondpapertextheight def
17
18 /lily-output-units 2.83464  def  %% milimeter
19 % /lily-output-units 0.996264  def  %% true points.
20
21 /output-scale
22 lilypondpaperoutputscale lily-output-units mul 
23 def
24
25 /set-ps-scale-to-lily-scale
26 {
27 output-scale output-scale scale
28 } bind def
29
30 /paper-size { lilypondpaperpapersize } bind def
31
32 %% FIXME: base-line-skip is too big, is this RIGHT?
33 %% /base-line-skip lilypondpaperlineheight def
34 /base-line-skip lilypondpaperlineheight lilypondpaperoutputscale div def
35
36 /init-paper {
37         gsave
38         .1 setlinewidth
39         clippath pathbbox newpath
40         /vsize exch def
41         /hsize exch def  pop pop pop
42
43         %FIXME:
44         %vsize text-height sub 2 div /top-margin exch def
45         % 144 2 div /top-margin exch def
46         /top-margin 100 def
47         hsize line-width sub 2 div /left-margin exch def
48         grestore
49 } bind def
50
51 /place-box
52 {
53         /object exch def
54         gsave
55         %exch translate
56         translate
57         0 0 moveto
58         object
59         grestore
60 } bind def
61
62 %% http://bibliofile.mc.duke.edu/gww/fonts/postscript-utilities/encoding-vectors.html
63
64 %/FONTLENGTH 256 bind def
65
66 %<font> <encoding> <name> reencode-font
67 /reencode-dict 5 dict def
68 /reencode-font
69 {
70     reencode-dict
71     begin
72     /name exch def
73     /encoding exch def
74     /base-font exch def
75     % note: Needs ps level 2
76     /font base-font maxlength dict def
77     base-font {
78         exch dup dup /FID ne exch /Encoding ne and
79         { exch font 3 1 roll put }
80         { pop pop } ifelse
81     } forall
82     font /FontName name put
83     font /Encoding encoding put
84     name font definefont pop
85     end
86 } bind def
87
88 /start-system % height
89 {
90         dup base-line-skip gt {
91                 /line-height exch def
92         }
93         {
94                 pop /line-height base-line-skip def
95         } ifelse
96         line-y top-margin sub base-line-skip lt {
97                 showpage
98                 /line-y vsize top-margin sub def
99         } if
100         gsave
101         line-x line-y translate
102 } bind def
103
104 /stop-system
105
106         /the-line exch def
107         the-line
108         stroke
109         grestore
110         line-y line-height output-scale mul sub /line-y exch def
111 } bind def
112
113 % FIXME: font definitions should come from LilyPond
114 %        built-in ps fonts are ugly
115 /huge-bold-font {
116         /Palatino-Bold findfont 20.7 scalefont setfont
117 } bind def
118
119 /Large-bold-font {
120         /Palatino-Bold findfont 17.3 scalefont setfont
121 } bind def
122
123 /large-bold-font {
124         /Palatino-Bold findfont 14.4 scalefont setfont
125 } bind def
126
127 /large-font {
128         /Palatino-Roman findfont 14.4 scalefont setfont
129 } bind def
130
131 /large-smallcaps-font {
132         % urg
133         /Bookman-Light findfont 14.4 scalefont setfont
134 } bind def
135
136 /normal-font {
137         /Palatino-Roman findfont 12 scalefont setfont
138 } bind def
139
140 /footnote-font {
141         /Palatino-Roman findfont 10 scalefont setfont
142 } bind def
143
144 /get-text-dimensions % path .. width height
145 {
146         dup true charpath pathbbox
147         newpath
148         line-x line-y moveto
149         exch 4 -1 roll
150         sub
151         3 1 roll
152         exch sub
153 } bind def
154
155 /set-centered
156 {
157         line-x line-y moveto
158         get-text-dimensions
159         neg line-y add /line-y exch def
160         neg line-width add 2 div 0 rmoveto
161         show
162 } bind def
163
164 /set-left
165 {
166         line-x line-y moveto
167         get-text-dimensions
168         neg line-y add /line-y exch def
169         pop
170         show
171 } bind def
172
173 /set-right
174 {
175         line-x line-y moveto
176         get-text-dimensions
177         neg line-y add /line-y exch def
178         neg line-width add 0 rmoveto
179         show
180 } bind def
181
182 /make-lilypond-title
183 {
184         currentdict /lilyponddedication known {
185                 normal-font lilyponddedication set-centered
186                 line-y 10 sub /line-y exch def
187         } if
188         currentdict /lilypondtitle known {
189                 huge-bold-font lilypondtitle set-centered
190                 line-y 5 sub /line-y exch def
191         } if
192         currentdict /lilypondsubtitle known {
193                 Large-bold-font lilypondsubtitle set-centered
194                 line-y 5 sub /line-y exch def
195         } if
196         currentdict /lilypondsubsubtitle known {
197                 large-bold-font lilypondsubsubtitle set-centered
198         } if
199         line-y /mini-page exch def
200         currentdict /lilypondcomposer known {
201                 large-smallcaps-font lilypondcomposer set-right
202                 line-y 2 sub /line-y exch def
203         } if
204         currentdict /lilypondopus known {
205                 normal-font lilypondopus set-right
206                 line-y 3 sub /line-y exch def
207         } if
208         currentdict /lilypondarranger known {
209                 normal-font lilypondarranger set-right
210                 line-y 3 sub /line-y exch def
211         } if
212         currentdict /lilypondpoet known {
213                 mini-page /line-y exch def
214                 normal-font lilypondpoet set-left
215                 line-y 3 sub /line-y exch def
216         } if
217         currentdict /lilypondtexttranslator known {
218                 normal-font lilypondtexttranslator set-left
219                 line-y 3 sub /line-y exch def
220         } if
221         currentdict /lilypondinstrument known {
222                 large-font lilypondinstrument set-centered
223         } if
224         currentdict /lilypondpiece known {
225                 large-smallcaps-font lilypondpiece set-left
226         } if
227 } bind def
228
229 /end-lilypond-output
230 {
231         /line-y top-margin def
232         footnote-font lilypondtagline set-left
233         showpage
234 } bind def
235
236 /turnOnExperimentalFeatures { } bind def
237
238 staff-line-thickness setlinewidth
239
240 % set postscript paper size
241 paper-size
242
243 % initialise paper dimensions
244 staff-height init-paper
245
246 /line-x left-margin output-scale div def
247 /line-y vsize top-margin sub def
248
249 % FIXME: testing \markup titles
250 % make-lilypond-title
251
252 % see if we're there...
253 % 10 setlinewidth 0 0 moveto 400 800 lineto stroke
254
255 % end lilyponddefs.ps