1 /***************************************************************************
2  * Copyright (C) 1991,1992 by Wei Sun (william@cs.anu.edu.au)
3  * All Rights Reserved
4  * Version 2.02
5  *
6  * File:gbpage.c
7  *
8  * DISTRIBUTION:
9  *      This program is NOT in public domain.
10  *      It can be freely distributed for non-commercial purposes only,
11  *      and THERE IS NO WARRANTY FOR THIS PROGRAM.
12  ****************************************************************************/
13 
14 #include "gb2ps.h"
15 
16 void
init_page()17 init_page()
18 {
19 /* define margins, line space and character space*/
20 	_LM=72;
21 	_RM=500;
22 	_TM=760;
23 	_BM=72;
24 	_FI=0;
25 	V=_TM; H=_LM;
26 	charcount=0; CFP=0;
27 	cfont=CHFONT[0].fp;
28 	font_height=CHFONT[0].height;
29 	font_width=CHFONT[0].width;
30 	page[0].offset=0;
31 	page[0].chfont=CFP;
32 	page[0].font_height=font_height;
33 	page[0].font_width=font_width;
34 	page[0]._LM=_LM;
35 	page[0]._RM=_RM;
36 	page[0]._TM=_TM;
37 	page[0]._BM=_BM;
38 	page[0]._FI=_FI;
39 	page[0].lineNo=0;
40 	page[1]=page[0];
41 }
42 
43 void
begin_page()44 begin_page()
45 {
46 
47 	if (!Analyse_flag) {
48 		if (pagecounter==page_end_print) return;
49 
50 /*		printf("Page:%d\n",pagecounter);*/
51 		printf(" %d",pagecounter); fflush(stdout);
52 
53 		fprintf(out,"%%%%Page: %d\n",pagecounter);
54 		fprintf(out,"/Courier findfont [%.2f 0 0 %.2f 0 0] makefont setfont\n",0.837*font_width,1.5*font_height);
55   		fprintf(out,"/H {moveto gsave currentpoint translate %d %d scale 24 24 true [24 0 0 -24 0 24]}def\n",font_width,font_height);
56 		fprintf(out,"save\n");
57 		if (setgray!=0)
58 			fprintf(out,"%.2f setgray\n",(float)setgray/100.0);
59 
60 	}
61 
62 	if (*stheader) {
63 		if (!Analyse_flag) {
64 			fprintf(out,"/tempdict 100 dict\ntempdict begin\n");
65 			fprintf(out,"/Courier findfont [%.2f 0 0 %.2f 0 0] makefont setfont\n",8.37,15.0);
66   			fprintf(out,"/H {moveto gsave currentpoint translate 10 10 scale 24 24 true [24 0 0 -24 0 24]}def\n");
67 			fprintf(out,"end\n");
68 		}
69 		V=_TM+24; H=_LM;
70 		putString(stheader);
71 		ASCshow();
72 	}
73 
74 		V=_TM-line_h[linecounter];	charcount=0;
75 }
76 
77 void
end_page()78 end_page ()
79 {
80 	if (pagecounter) {
81 		ASCshow();
82 		if (!Analyse_flag) {
83 			fprintf(out,"/Courier findfont [%.2f 0 0 %.2f 0 0] makefont setfont\n",8.37,15.0);
84   			fprintf(out,"/H {moveto gsave currentpoint translate 10 10 scale 24 24 true [24 0 0 -24 0 24]}def\n");
85 		}
86 		if (*stfooter) {
87 			H=_LM; V=48;
88 			putString(stfooter);
89 			ASCshow();
90 		}
91 		if (!Analyse_flag) {
92 		  	if (pageno_flag) {
93 				fprintf(out,"%d %d M (%d) S\n",
94 					300,_BM-24,pagecounter);
95 			}
96 		  	fprintf(out,"endpage\n");
97 		}
98 	}
99 	pagecounter++;
100 }
101 
102 void
ps_header()103 ps_header ()
104 {
105   fprintf(out,"%%!PS-Adobe-1.0\n");
106   fprintf(out,"%%%%Creator: W. SUN, ANU\n");
107   fprintf(out,"/endpage {showpage restore} def\n");
108   fprintf(out,"/G /grestore load def\n");
109   fprintf(out,"/I /imagemask load def\n");
110   fprintf(out,"/M /moveto load def\n");
111   fprintf(out,"/S /show load def\n");
112   DefCHdict();
113   fprintf(out,"%%%%EndProlog\n");
114 }
115 
116 void
ps_end()117 ps_end()
118 {
119 	fprintf(out,"%%%%Trailer\n");
120 }
121