Introduction
Introduction Statistics Contact Development Disclaimer Help
pssubs.h - abc2ps - A powerful sheet setting tool using the simple abc notation
git clone git://vernunftzentrum.de/abc2ps.git
Log
Files
Refs
---
pssubs.h (10391B)
---
1 /*
2 * This file is part of abc2ps,
3 * Copyright (C) 1996,1997,1998 Michael Methfessel
4 * See file abc2ps.c for details.
5 */
6
7 /* subroutines for postscript output */
8
9
10 /* ----- level1_fix: special defs for level 1 Postscript ------- */
11 void level1_fix (fp)
12 FILE *fp;
13 {
14
15 fprintf (fp,
16 "/selectfont { exch findfont exch dup %% emulate level 2 op…
17 " type /arraytype eq {makefont}{scalefont} ifelse setfont\n"
18 "} bind def\n"
19 );
20
21 /* fix to define ISOLatin1Encoding for ps level 1 (david weisman) */
22
23 fprintf (fp,
24 "/ISOLatin1Encoding\n"
25 "[ /.notdef /.notdef /.notdef /.notdef\n"
26 "/.notdef /.notdef /.notdef /.notdef\n"
27 "/.notdef /.notdef /.notdef /.notdef\n"
28 "/.notdef /.notdef /.notdef /.notdef\n"
29 "/.notdef /.notdef /.notdef /.notdef\n"
30 "/.notdef /.notdef /.notdef /.notdef\n"
31 "/.notdef /.notdef /.notdef /.notdef\n"
32 "/.notdef /.notdef /.notdef /.notdef\n"
33 "/space /exclam /quotedbl /numbersign\n"
34 "/dollar /percent /ampersand /quoteright\n"
35 "/parenleft /parenright /asterisk /plus\n"
36 "/comma /hyphen /period /slash\n"
37 "/zero /one /two /three\n"
38 "/four /five /six /seven\n"
39 "/eight /nine /colon /semicolon\n"
40 "/less /equal /greater /question\n"
41 "/at /A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X…
42 "/backslash /bracketright/asciicircum/underscore\n"
43 "/quoteleft /a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x…
44 "/bar /braceright/asciitilde /.notdef\n"
45 "/.notdef /.notdef /.notdef /.notdef\n"
46 "/.notdef /.notdef /.notdef /.notdef\n"
47 "/.notdef /.notdef /.notdef /.notdef\n"
48 "/.notdef /.notdef /.notdef /.notdef\n"
49 "/dotlessi /grave /acute /circumflex\n"
50 "/tilde /macron /breve /dotaccent\n"
51 "/dieresis /.notdef /ring /cedilla\n"
52 "/.notdef /hungarumlaut/ogonek /caron\n"
53 "/space /exclamdown /cent /sterling\n"
54 "/currency /yen /brokenbar /section\n"
55 "/dieresis /copyright /ordfeminine/guillemotleft\n"
56 "/logicalnot /hyphen /registered /macron\n"
57 "/degree /plusminus /twosuperior/threesuperior\n"
58 "/acute /mu /paragraph /periodcentered\n"
59 "/cedilla /onesuperior/ordmasculine/guillemotright\n"
60 "/onequarter /onehalf /threequarters/questiondown\n"
61 "/Agrave /Aacute /Acircumflex/Atilde\n"
62 "/Adieresis /Aring /AE /Ccedilla\n"
63 "/Egrave /Eacute /Ecircumflex/Edieresis\n"
64 "/Igrave /Iacute /Icircumflex/Idieresis\n"
65 "/Eth /Ntilde /Ograve /Oacute\n"
66 "/Ocircumflex/Otilde /Odieresis /multiply\n"
67 "/Oslash /Ugrave /Uacute /Ucircumflex\n"
68 "/Udieresis /Yacute /Thorn /germandbls\n"
69 "/agrave /aacute /acircumflex/atilde\n"
70 "/adieresis /aring /ae /ccedilla\n"
71 "/egrave /eacute /ecircumflex/edieresis\n"
72 "/igrave /iacute /icircumflex/idieresis\n"
73 "/eth /ntilde /ograve /oacute\n"
74 "/ocircumflex/otilde /odieresis /divide\n"
75 "/oslash /ugrave /uacute /ucircumflex\n"
76 "/udieresis /yacute /thorn /ydieresis\n"
77 "] def\n\n"
78 );
79
80 /* end fix to define ISOLatin1Encoding for ps level 1 */
81
82
83 }
84
85 /* ----- init_ps ------- */
86 void init_ps (fp,str,is_epsf,bx1,by1,bx2,by2)
87 FILE *fp;
88 char str[];
89 int is_epsf;
90 float bx1,bx2,by1,by2;
91 {
92 time_t ltime;
93 char tstr[41];
94 int i;
95
96 if (is_epsf) {
97 if (vb>=8) printf("Open EPS file with title \"%s\"\n", str);
98 fprintf (fp, "%%!PS-Adobe-3.0 EPSF-3.0\n");
99 fprintf (fp, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n",
100 bx1,by1,bx2,by2);
101 }
102 else {
103 if (vb>=8) printf("Open PS file with title \"%s\"\n", str);
104 fprintf (fp, "%%!PS-Adobe-3.0\n");
105 }
106
107 /* Title */
108 fprintf (fp, "%%%%Title: %s\n", str);
109
110 /* CreationDate */
111 time(&ltime);
112 strcpy (tstr, ctime(&ltime));
113 tstr[24]='\0';
114 tstr[16]='\0';
115 fprintf (fp, "%%%%Creator: abc2ps %s.%s\n", VERSION, REVISION);
116 fprintf (fp, "%%%%CreationDate: %s %s\n", tstr+4,tstr+20);
117
118 if (PS_LEVEL == 2) fprintf (fp, "%%%%LanguageLevel: 2\n");
119 fprintf (fp, "%%%%EndComments\n\n");
120
121 if (is_epsf)
122 fprintf (fp, "gsave /origstate save def mark\n100 dict begin\n\n");
123
124 fprintf (fp, "%%%%BeginSetup\n");
125 if (PS_LEVEL < 2) level1_fix (fp);
126 if (vb>=7) printf ("\nDefining ISO fonts in file header:\n");
127 for (i=0;i<nfontnames;i++) {
128 define_font (fp,fontnames[i],i);
129 if (vb>=7) printf (" F%d %s\n", i,fontnames[i]);
130 }
131 define_symbols (fp);
132 fprintf (fp, "\n0 setlinecap 0 setlinejoin 0.8 setlinewidth\n");
133 fprintf (fp, "\n/T {translate} bind def\n/M {moveto} bind def\n");
134 fprintf (fp, "%%%%EndSetup\n");
135 file_initialized=1;
136 }
137
138 /* ----- close_ps ------- */
139 void close_ps (fp)
140 FILE *fp;
141 {
142 if(vb>=8) printf ("closing PS file\n");
143 fprintf (fp,
144 "%%EOF\n\n"
145 );
146 }
147
148 /* ----- init_page: initialize postscript page ----- */
149 void init_page (fp)
150 FILE *fp;
151 {
152
153 if (vb>=10) printf ("init_page called; in_page=%d\n", in_page);
154 if (in_page) return;
155
156 if (!file_initialized) {
157 if (vb>=10) printf ("file not yet initialized; do it now\n");
158 init_ps (fp,infostr, 0,0.0,0.0,0.0,0.0);
159 }
160 in_page=1;
161 pagenum++;
162
163 if (verbose==0) ;
164 else if (verbose==1) printf ("[%d] ", pagenum);
165 else if (verbose==2) printf ("[%d] ", pagenum);
166 else printf ("[%d]\n", pagenum);
167 fflush (stdout);
168 fprintf (fp,
169 "\n%% --- page %d\n"
170 "%%%%Page: %d %d\n"
171 "%%%%BeginPageSetup\n",
172 pagenum, pagenum, pagenum);
173
174 if (cfmt.landscape) fprintf(fp,"%%%%PageOrientation: Landscape\n");
175 fprintf(fp,"gsave ");
176 if (cfmt.landscape) fprintf(fp,"90 rotate 0 %.1f translate ",
177 -cfmt.pageheight);
178 fprintf (fp,"%.2f %.2f translate\n",
179 cfmt.leftmargin, cfmt.pageheight-cfmt.topmargin);
180 fprintf (fp, "%%%%EndPageSetup\n");
181
182
183 /* write page number */
184 if (pagenumbers) {
185 fprintf (fp, "/Times-Roman 12 selectfont ");
186
187 /* page numbers always at right */
188 fprintf(fp, "%.1f %.1f moveto (%d) /bx false def lshow\n",
189 cfmt.staffwidth, cfmt.topmargin-30.0, pagenum);
190
191 /* page number right/left for odd/even pages */
192 /*| if (pagenum%2==0) |*/
193 /*| fprintf(fp, "%.1f %.1f moveto (%d) show\n", |*/
194 /*| 0.0, cfmt.topmargin-30.0, pagenum); |*/
195 /*| else |*/
196 /*| fprintf(fp, "%.1f %.1f moveto (%d) lshow\n", |*/
197 /*| cfmt.staffwidth, cfmt.topmargin-30.0, pagenum); |*/
198
199 }
200
201 }
202
203 /* ----- init_index_page ----- */
204 void init_index_page (fp)
205 FILE *fp;
206 {
207 float hsize;
208
209 index_pagenum++;
210
211 fprintf (fp,
212 "\n%% --- page %d\n"
213 "%%%%Page: %d %d\n"
214 "%%%%BeginPageSetup\n",
215 index_pagenum, index_pagenum, index_pagenum);
216
217 if (cfmt.landscape) fprintf(fp,"%%%%PageOrientation: Landscape\n");
218 if (cfmt.landscape) fprintf(fp,"90 rotate 0 %.1f translate ",
219 -cfmt.pageheight);
220 fprintf (findex, "gsave\n");
221 fprintf (fp, "%%%%EndPageSetup\n\n");
222
223 index_posx=cfmt.leftmargin;
224 index_posy=cfmt.pageheight-cfmt.topmargin;
225 /* extra space at top.. */
226
227 index_posy = index_posy - 2*cfmt.indexfont.size;
228
229 /* write heading */
230 if (index_pagenum == 1) {
231 hsize = 1.5*cfmt.indexfont.size;
232 index_posy = index_posy - hsize;
233 fprintf (findex, "%.1f %d F1 \n", hsize,cfmt.indexfont.box);
234 fprintf (findex, "%.2f %.2f M (Contents) S\n", index_posx, index_pos…
235 index_posy = index_posy - cfmt.indexfont.size;
236 }
237
238 fprintf (findex, "%.1f %d F1 \n",
239 cfmt.indexfont.size, cfmt.indexfont.box);
240
241 }
242
243
244
245 /* ----- init_index_file ------- */
246 void init_index_file ()
247 {
248 time_t ltime;
249 char tstr[41];
250
251 fprintf (findex, "%%!PS-Adobe-3.0\n");
252 fprintf (findex, "%%%%Title: abc2ps index\n");
253 time(&ltime);
254 strcpy (tstr, ctime(&ltime));
255 tstr[24]='\0';
256 tstr[16]='\0';
257 fprintf (findex, "%%%%Creator: abc2ps %s.%s\n", VERSION, REVISION);
258 fprintf (findex, "%%%%CreationDate: %s %s\n", tstr+4,tstr+20);
259 if (PS_LEVEL == 2) fprintf (findex, "%%%%LanguageLevel: 2\n");
260 fprintf (findex, "%%%%EndComments\n\n");
261
262 fprintf (findex, "%%%%BeginSetup\n");
263 if (PS_LEVEL < 2) level1_fix (findex);
264
265 define_font (findex,cfmt.indexfont.name,1);
266 fprintf (findex, "\n/T {translate} bind def\n/M {moveto} bind def\n");
267 fprintf (findex, "/S {show} bind def\n");
268 def_misc (findex);
269 fprintf (findex, "%%%%EndSetup\n\n");
270
271 index_pagenum=0;
272 init_index_page (findex);
273
274 index_initialized=1;
275
276 }
277
278
279 /* ----- close_index_page-------- */
280 void close_index_page (fp)
281 FILE *fp;
282 {
283
284 fprintf (fp,
285 "\n%%%%PageTrailer\n"
286 "grestore\n"
287 "showpage\n");
288 }
289
290
291 /* ----- close_page-------- */
292 void close_page (fp)
293 FILE *fp;
294 {
295 if (vb>=10) printf ("close_page called; in_page=%d\n", in_page);
296
297 if (! in_page) return;
298 in_page=0;
299
300 fprintf (fp,
301 "\n%%%%PageTrailer\n"
302 "grestore\n"
303 "showpage\n");
304 }
305
306
307 /* ----- init_epsf: initialize epsf file ----- */
308 void init_epsf (fp)
309 FILE *fp;
310 {
311 float px,py;
312 px=cfmt.leftmargin;
313 py=cfmt.pageheight-cfmt.topmargin;
314 fprintf (fp, "%.2f %.2f translate\n", px, py);
315 }
316
317 /* ----- close_epsf: close epsf file ----- */
318 void close_epsf (fp)
319 FILE *fp;
320 {
321 fprintf (fp,
322 "\nshowpage\nend\n"
323 "cleartomark origstate restore grestore\n\n");
324 }
325
326
327 /* ----- write_pagebreak ----- */
328 void write_pagebreak (fp)
329 FILE *fp;
330 {
331
332 close_page (fp);
333 init_page (fp);
334 if (strlen(page_init)>0) fprintf(fp,"%s\n", page_init);
335 posy=cfmt.pageheight-cfmt.topmargin;
336
337 }
338
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.