1From jonas Thu Nov 19 19:08:48 1992
2Received: by ada id AA18758
3  (5.65c8/IDA-1.4.4 for jonas); Thu, 19 Nov 1992 19:08:13 +0100
4From: Jonas Lagerblad <jonas>
5Message-Id: <199211191808.AA18758@ada>
6Subject: Regarding nenscript-1.13
7To: geoffw@extro.ucc.su.oz.au
8Date: Thu, 19 Nov 92 19:08:10 MET
9Cc: jonas (Jonas Lagerblad)
10X-Mailer: ELM [version 2.3 PL11]
11X-Charset: LATIN1
12X-Char-Esc: 29
13Status: OR
14
15The email address given in all files seems to be wrong, I had no success at all
16with geoffw@extro.ucc.oz.au, this is an attempt to write to extro.ucc.su.oz.au.
17
18Please forward this to the maintainer of nenscript.
19
20I have made some modifications of nenscript 1.13, to allow it to compile
21on ultrix 4.2, to be able to print documents containing ISO Latin1 characters,
22and to allow fractions of a point to be given as character size.
23
24Thank You for a nice and useful program. I have attached the diffs below,
25please use them if they fit your plans. There is one thing that you might
26want to change, my function ChgFnt does a setfont and I removed all your
27setfonts from other places, this is really a matter of taste.
28
29Regards
30Jonas Lagerblad
31Phone Office: +46-31-830250 Home: +46-31-205955 Car: +46-10-2846031
32FAX:	+46-31-831047
33email:	jonas@sisu.se
34
35diff -c /home/sisug/jonas/Dos/nenscript/fontwidt.c ./fontwidt.c
36*** /home/sisug/jonas/Dos/nenscript/fontwidt.c	Thu Oct  1 18:02:48 1992
37--- ./fontwidt.c	Thu Nov 19 18:42:59 1992
38***************
39*** 11,16 ****
40--- 11,17 ----
41   *   (or money, cheques, free trips =8^) !!!!! ) please contact me
42   *   care of geoffw@extro.ucc.oz.au
43   *
44+  *   Ugly fix for fractions of points by Jonas Lagerblad (jonas@sisu.se)
45   */
46
47  #include "machdep.h"
48***************
49*** 77,82 ****
50--- 78,84 ----
51  long  size;
52
53  {
54+   int rem = size % 100;
55    size /= 100;
56
57    if (strcmp (fontname, "Courier") != 0) {
58***************
59*** 84,93 ****
60      exit (1);
61    }
62
63!   if (size < 5 || size > 30) {
64      fprintf (stderr, "%s: %i not bwteen valid font sizes of 5 and 30 - sorry!!\n", progname, size);
65      exit (1);
66    }
67
68    return CourierFontWidths [size-5];
69  }
70--- 86,100 ----
71      exit (1);
72    }
73
74!   if (size < 5 || size > 30 || (size == 30 && rem > 0)) {
75      fprintf (stderr, "%s: %i not bwteen valid font sizes of 5 and 30 - sorry!!\n", progname, size);
76      exit (1);
77    }
78+   if (rem > 0) {
79+       /* make an linear approximation of font size */
80+       return CourierFontWidths [size-5] +
81+ 	  (CourierFontWidths [size-4] - CourierFontWidths [size-5]) * rem/100;
82+   }
83
84    return CourierFontWidths [size-5];
85  }
86diff -c /home/sisug/jonas/Dos/nenscript/machdep.h ./machdep.h
87*** /home/sisug/jonas/Dos/nenscript/machdep.h	Thu Oct  1 16:06:22 1992
88--- ./machdep.h	Thu Nov 19 14:34:27 1992
89***************
90*** 45,51 ****
91  # define	LPR		"lpr -P "		/* spooler with option to set name of printer */
92
93  # define	STRICMP(s1,s2)	strcasecmp(s1,s2)
94! # define	STRDUP(str)	strdup(str)
95
96  # define	USERNAME	((getpwuid (getuid()))->pw_name)
97
98--- 45,55 ----
99  # define	LPR		"lpr -P "		/* spooler with option to set name of printer */
100
101  # define	STRICMP(s1,s2)	strcasecmp(s1,s2)
102! # ifdef ultrix
103! #  define	STRDUP(str)	strcpy(malloc(strlen(str)+1), str)
104! # else
105! #  define	STRDUP(str)	strdup(str)
106! # endif
107
108  # define	USERNAME	((getpwuid (getuid()))->pw_name)
109
110diff -c /home/sisug/jonas/Dos/nenscript/makefile ./makefile
111*** /home/sisug/jonas/Dos/nenscript/makefile	Thu Oct  1 18:03:16 1992
112--- ./makefile	Thu Nov 19 18:23:19 1992
113***************
114*** 33,38 ****
115--- 33,39 ----
116  CP	=	cp
117  RM	=	rm
118  INSTALL	=	/etc/install
119+ INSTALL	=	install
120
121  all debug:	$(PROG)
122
123***************
124*** 42,48 ****
125  main.$(OBJ):	main.c
126
127  install: $(PROG)
128! 	$(INSTALL) -f $(BININSTALLDIR) -s -m 555 $(PROG)
129
130  install.man: $(MAN)
131  	$(INSTALL) -f $(MAININSTALLDIR) -m 444 $(MAN)
132--- 43,50 ----
133  main.$(OBJ):	main.c
134
135  install: $(PROG)
136! 	$(INSTALL) -s -m 555 $(PROG) $(BININSTALLDIR)
137! 	$(INSTALL) -m 444 $(MAN) $(MANINSTALLDIR)
138
139  install.man: $(MAN)
140  	$(INSTALL) -f $(MAININSTALLDIR) -m 444 $(MAN)
141diff -c /home/sisug/jonas/Dos/nenscript/nenscript.1 ./nenscript.1
142*** /home/sisug/jonas/Dos/nenscript/nenscript.1	Wed Oct  7 14:59:56 1992
143--- ./nenscript.1	Thu Nov 19 18:21:12 1992
144***************
145*** 48,54 ****
146
147  Font specifications are formed from the font name and the font size, i.e.
148  .B Courier10
149! specifies a 10 point Courier font, and Courier-Bold12 specifies a bold, 12 point Courier font.
150
151  The NENSCRIPT environment variable may be used to set default values for most
152  configurable attributes. Values set in this way will be overridden by any
153--- 48,58 ----
154
155  Font specifications are formed from the font name and the font size, i.e.
156  .B Courier10
157! specifies a 10 point Courier font, and Courier-Bold12 specifies a bold, 12 point Courier font. Sizes can also be given with a decimal point, i.e.
158! .B Courier7.5
159! specifies a 7.5 point font, this might however result in a marginal error in
160! the size calculations, since a linear approximation of the character width
161! is done.
162
163  The NENSCRIPT environment variable may be used to set default values for most
164  configurable attributes. Values set in this way will be overridden by any
165diff -c /home/sisug/jonas/Dos/nenscript/postscri.c ./postscri.c
166*** /home/sisug/jonas/Dos/nenscript/postscri.c	Thu Oct  1 18:02:52 1992
167--- ./postscri.c	Thu Nov 19 18:41:52 1992
168***************
169*** 11,16 ****
170--- 11,18 ----
171   *   (or money, cheques, free trips =8^) !!!!! ) please contact me
172   *   care of geoffw@extro.ucc.oz.au
173   *
174+  *   Latin1 caracter set handling and fraction point sizes added by
175+  *   Jonas Lagerblad (jonas@sisu.se).
176   */
177
178  #include "machdep.h"
179***************
180*** 86,92 ****
181   */
182
183  #ifdef __STDC__
184! void          PrintPSString   (FILE *, char *, long);
185  void          EndPage         (FILE *);
186  void          StartPage       (FILE *);
187  void          PrintLine       (FILE *, char *, long, int);
188--- 88,94 ----
189   */
190
191  #ifdef __STDC__
192! void          PrintPSString   (FILE *, unsigned char *, long);
193  void          EndPage         (FILE *);
194  void          StartPage       (FILE *);
195  void          PrintLine       (FILE *, char *, long, int);
196***************
197*** 107,122 ****
198  void PrintPSString (stream, line, len)
199
200  FILE *stream;
201! char *line;
202  long len;
203
204  {
205    register long i;
206!   register char * str = line;
207
208    fprintf (stream, "(");
209    for (i = 0; i < len ; i++)
210!     fprintf (stream, "%s%c", str[i] == ')'  ||
211                               str[i] == '('  ||
212  			     str[i] == '\\' ? "\\" : "", str[i]);
213    fprintf (stream, ")");
214--- 109,127 ----
215  void PrintPSString (stream, line, len)
216
217  FILE *stream;
218! unsigned char *line;
219  long len;
220
221  {
222    register long i;
223!   register unsigned char * str = line;
224
225    fprintf (stream, "(");
226    for (i = 0; i < len ; i++)
227!       if ( str[i] & 0x80 )
228! 	  fprintf (stream, "\\%03o", str[i]);
229!       else
230! 	  fprintf (stream, "%s%c", str[i] == ')'  ||
231                               str[i] == '('  ||
232  			     str[i] == '\\' ? "\\" : "", str[i]);
233    fprintf (stream, ")");
234***************
235*** 136,151 ****
236  {
237    char *p, *s, *t;
238    int i;
239
240    /* get ptr to end of string */
241    p = &font[strlen(font)-1];
242
243    /* move backwards until we find a character that is not a digit */
244!   while (p > font && isdigit (*p))
245      p--;
246
247    /* extract the font size */
248!   *fontsize = atol (++p) * SCALE;
249
250    /* now duplicate and copy the font name */
251    t = s = (char *)malloc (p - font + 1);
252--- 141,157 ----
253  {
254    char *p, *s, *t;
255    int i;
256+   extern double atof();
257
258    /* get ptr to end of string */
259    p = &font[strlen(font)-1];
260
261    /* move backwards until we find a character that is not a digit */
262!   while (p > font && (isdigit (*p) || *p == '.'))
263      p--;
264
265    /* extract the font size */
266!   *fontsize = atof (++p) * SCALE;
267
268    /* now duplicate and copy the font name */
269    t = s = (char *)malloc (p - font + 1);
270***************
271*** 366,371 ****
272--- 372,438 ----
273      EndPage (stream);
274  }
275
276+     static char pspro_latin1_data[] = { "\
277+ /newcodes	% foreign character encodings\n\
278+ [\n\
279+ 160/space 161/exclamdown 162/cent 163/sterling 164/currency\n\
280+ 165/yen 166/brokenbar 167/section  168/dieresis 169/copyright\n\
281+ 170/ordfeminine 171/guillemotleft 172/logicalnot 173/hyphen 174/registered\n\
282+ 175/macron 176/degree 177/plusminus 178/twosuperior 179/threesuperior\n\
283+ 180/acute 181/mu 182/paragraph  183/periodcentered 184/cedilla\n\
284+ 185/onesuperior 186/ordmasculine 187/guillemotright 188/onequarter\n\
285+ 189/onehalf 190/threequarters 191/questiondown 192/Agrave 193/Aacute\n\
286+ 194/Acircumflex 195/Atilde 196/Adieresis 197/Aring 198/AE 199/Ccedilla\n\
287+ 200/Egrave 201/Eacute 202/Ecircumflex 203/Edieresis 204/Igrave  205/Iacute\n\
288+ 206/Icircumflex 207/Idieresis 208/Eth 209/Ntilde 210/Ograve 211/Oacute\n\
289+ 212/Ocircumflex 213/Otilde  214/Odieresis 215/multiply 216/Oslash\n\
290+ 217/Ugrave 218/Uacute 219/Ucircumflex 220/Udieresis 221/Yacute 222/Thorn\n\
291+ 223/germandbls 224/agrave 225/aacute 226/acircumflex 227/atilde\n\
292+ 228/adieresis 229/aring 230/ae 231/ccedilla  232/egrave 233/eacute\n\
293+ 234/ecircumflex 235/edieresis 236/igrave 237/iacute 238/icircumflex\n\
294+ 239/idieresis 240/eth 241/ntilde 242/ograve 243/oacute 244/ocircumflex\n\
295+ 245/otilde 246/odieresis 247/divide 248/oslash 249/ugrave  250/uacute\n\
296+ 251/ucircumflex 252/udieresis 253/yacute 254/thorn 255/ydieresis\n\
297+ ] def\n\
298+ \n\
299+ /reencdict 12 dict def\n\
300+ \n\
301+ " };
302+
303+     static char pspro_latin1_func[] = { "\n\
304+     % change fonts using ISO Latin1 characters\n\
305+ /ChgFnt		% size psname natname  =>  font\n\
306+ {\n\
307+     dup FontDirectory exch known	% is re-encoded name known?\n\
308+     { exch pop }			% yes, get rid of long name\n\
309+     { dup 3 1 roll ReEncode } ifelse	% no, re-encode it\n\
310+     findfont exch scalefont setfont\n\
311+ } def\n\
312+ \n\
313+ /ReEncode	%\n\
314+ {\n\
315+     reencdict begin\n\
316+ 	/newname exch def\n\
317+ 	/basename exch def\n\
318+ 	/basedict basename findfont def\n\
319+ 	/newfont basedict maxlength dict def\n\
320+ 	basedict\n\
321+ 	{ exch dup /FID ne\n\
322+ 	    { dup /Encoding eq\n\
323+ 		{ exch dup length array copy newfont 3 1 roll put }\n\
324+ 		{ exch newfont 3 1 roll put } ifelse\n\
325+ 	    }\n\
326+ 	    { pop pop } ifelse\n\
327+ 	} forall\n\
328+ 	newfont /FontName newname put\n\
329+ 	newcodes aload pop newcodes length 2 idiv\n\
330+ 	{ newfont /Encoding get 3 1 roll put } repeat\n\
331+ 	newname newfont definefont pop\n\
332+     end\n\
333+ } def\n\
334+ \n\
335+ " };
336+
337  /********************************
338    StartJob
339      Called when a new job is to be started. This performs all of the
340***************
341*** 480,485 ****
342--- 547,555 ----
343    /* End of header marker */
344    fprintf (stream, "%%%%EndComments\n");
345
346+   /* allow Latin-1 character set by remapping most characters above 127 */
347+   fprintf (stream, "%s\n%s", pspro_latin1_data, pspro_latin1_func);
348+
349    /* scale the coordinate system by SCALE so we can use integer arithmetic
350       without losing accuracy */
351    fprintf (stream, "1 %li div dup scale\n", SCALE);
352***************
353*** 551,565 ****
354    }
355
356    /* define a variable for our body font, and calculate the character width for later use */
357!   fprintf (stream, "/BodyF /%s findfont %li scalefont def\n", bodyfont, BFH);
358!   fprintf (stream, "/CW BodyF setfont ( ) stringwidth pop def\n");
359
360    /* define variables for various other font used - title, gaudy page number, gaudy date, gaudy title */
361!   fprintf (stream, "/Titlef  /%s findfont %li scalefont def\n", titlefont, TFH);
362    if (GaudyFlag) {
363!     fprintf (stream, "/Gpnf    /%s findfont %li scalefont def\n", gaudyPNfont,    gaudyPNfontsize);
364!     fprintf (stream, "/Gdatef  /%s findfont %li scalefont def\n", gaudydatefont,  gaudydatefontsize);
365!     fprintf (stream, "/Gtitlef /%s findfont %li scalefont def\n", gaudytitlefont, gaudytitlefontsize);
366    }
367
368    /* define procedures for drawing continuation line markers, continuation lines, normal lines, and performing indents */
369--- 621,640 ----
370    }
371
372    /* define a variable for our body font, and calculate the character width for later use */
373!   fprintf (stream, "/BodyF { %li /%s /%s-Latin1 ChgFnt } def\n", BFH, bodyfont,
374!      bodyfont, BFH);
375!   fprintf (stream, "/CW BodyF ( ) stringwidth pop def\n");
376
377    /* define variables for various other font used - title, gaudy page number, gaudy date, gaudy title */
378!   fprintf (stream, "/Titlef {  %li /%s /%s-Latin1 ChgFnt } def\n", TFH, titlefont,
379!      titlefont);
380    if (GaudyFlag) {
381!     fprintf (stream, "/Gpnf {  %li /%s /%s-Latin1 ChgFnt } def\n", gaudyPNfontsize,
382!      gaudyPNfont, gaudyPNfont);
383!     fprintf (stream, "/Gdatef { %li /%s /%s-Latin1 ChgFnt } def\n",
384!      gaudydatefontsize, gaudydatefont, gaudydatefont);
385!     fprintf (stream, "/Gtitlef { %li /%s /%s-Latin1 ChgFnt } def\n",
386!      gaudytitlefontsize, gaudytitlefont, gaudytitlefont);
387    }
388
389    /* define procedures for drawing continuation line markers, continuation lines, normal lines, and performing indents */
390***************
391*** 588,594 ****
392
393    /* define stuff for security strings */
394    if (Classification != NULL) {
395!     fprintf (stream, "/Classf  /%s findfont %li scalefont def\n", classfont, classfontsize);
396      fprintf (stream, "/ClassString ");
397      PrintPSString (stream, Classification, strlen(classification));
398      fprintf (stream, " def\n");
399--- 663,670 ----
400
401    /* define stuff for security strings */
402    if (Classification != NULL) {
403!     fprintf (stream, "/Classf {  %li /%s /%s-Latin1 ChgFnt } def\n", classfontsize,
404!      classfont, classfont);
405      fprintf (stream, "/ClassString ");
406      PrintPSString (stream, Classification, strlen(classification));
407      fprintf (stream, " def\n");
408***************
409*** 598,609 ****
410    /* define the start page procedure used to start every page */
411    fprintf (stream, "/StartPage { /SavedPage save def\n");
412    if (Classification != NULL)
413!       fprintf (stream, "  Classf setfont %li %li moveto ClassString Centre 0 setgray show\n", PW / 2, ClassY);
414
415    if (TitleEnabled) {
416      if (GaudyFlag) {
417        fprintf (stream, "  G\n");                                                   /* draw boxes */
418!       fprintf (stream, "  Gtitlef setfont %li %li moveto Centre 0 setgray show\n",   /* title */
419                                           ((LM + (papermetrics->GaudyBoxWidth  * SCALE)) +
420                                             (PW - RM - (papermetrics->GaudyBoxWidth  * SCALE))) / 2L,
421                                           TitleY - (papermetrics->GaudyBoxHeight * SCALE) +
422--- 674,685 ----
423    /* define the start page procedure used to start every page */
424    fprintf (stream, "/StartPage { /SavedPage save def\n");
425    if (Classification != NULL)
426!       fprintf (stream, "  Classf %li %li moveto ClassString Centre 0 setgray show\n", PW / 2, ClassY);
427
428    if (TitleEnabled) {
429      if (GaudyFlag) {
430        fprintf (stream, "  G\n");                                                   /* draw boxes */
431!       fprintf (stream, "  Gtitlef %li %li moveto Centre 0 setgray show\n",   /* title */
432                                           ((LM + (papermetrics->GaudyBoxWidth  * SCALE)) +
433                                             (PW - RM - (papermetrics->GaudyBoxWidth  * SCALE))) / 2L,
434                                           TitleY - (papermetrics->GaudyBoxHeight * SCALE) +
435***************
436*** 615,624 ****
437          PrintPSString (stream, title, strlen(title));
438          fprintf (stream, " Centre show\n");
439        }
440!       fprintf (stream, "  Gpnf    setfont %li %li moveto Centre 1 setgray show\n",   /* page number */
441                                           PW - RM - ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
442                                           TitleY - ((papermetrics->GaudyBoxHeight * SCALE) / 2L) - gaudyPNfontsize * 7L / 20L);
443!       fprintf (stream, "  Gdatef  setfont %li %li moveto (%s) Centre 0 setgray show\n",
444  					 LM + ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
445  					 TitleY - ((papermetrics->GaudyBoxHeight * SCALE) * 3L / 5L) - gaudydatefontsize * 7L / 10L, tm_string);
446        fprintf (stream, "                  %li %li moveto (%s) Centre show\n",
447--- 691,700 ----
448          PrintPSString (stream, title, strlen(title));
449          fprintf (stream, " Centre show\n");
450        }
451!       fprintf (stream, "  Gpnf    %li %li moveto Centre 1 setgray show\n",   /* page number */
452                                           PW - RM - ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
453                                           TitleY - ((papermetrics->GaudyBoxHeight * SCALE) / 2L) - gaudyPNfontsize * 7L / 20L);
454!       fprintf (stream, "  Gdatef  %li %li moveto (%s) Centre 0 setgray show\n",
455  					 LM + ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
456  					 TitleY - ((papermetrics->GaudyBoxHeight * SCALE) * 3L / 5L) - gaudydatefontsize * 7L / 10L, tm_string);
457        fprintf (stream, "                  %li %li moveto (%s) Centre show\n",
458***************
459*** 625,631 ****
460  					 LM + ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
461  					 TitleY - ((papermetrics->GaudyBoxHeight * SCALE) * 3L / 5L) + gaudydatefontsize * 7L / 10L, dt_string);
462      } else {
463!       fprintf (stream, "  0 setgray Titlef setfont %li %li moveto ", LM, TitleY);
464        if (title != NULL) {
465          fprintf (stream, "pop pop ");
466          PrintPSString (stream, title, strlen(title));
467--- 701,707 ----
468  					 LM + ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
469  					 TitleY - ((papermetrics->GaudyBoxHeight * SCALE) * 3L / 5L) + gaudydatefontsize * 7L / 10L, dt_string);
470      } else {
471!       fprintf (stream, "  0 setgray Titlef %li %li moveto ", LM, TitleY);
472        if (title != NULL) {
473          fprintf (stream, "pop pop ");
474          PrintPSString (stream, title, strlen(title));
475***************
476*** 637,643 ****
477        }
478      }
479    }
480!   fprintf (stream, "  BodyF setfont 0 setgray } def\n");
481
482    /* define end page procedure */
483    fprintf (stream, "/EndPage   {");
484--- 713,719 ----
485        }
486      }
487    }
488!   fprintf (stream, "  BodyF 0 setgray } def\n");
489
490    /* define end page procedure */
491    fprintf (stream, "/EndPage   {");
492***************
493*** 644,650 ****
494    if (GaudyFlag && Columns == 2)
495      fprintf (stream, " %li %li moveto %li -%li rlineto stroke ", LM + WW + (papermetrics->ColumnSep * SCALE / 2), StartY, 0L, StartY - EndY);
496    if (Classification != NULL)
497!       fprintf (stream, "  Classf setfont %li %li moveto ClassString Centre 0 setgray show\n", PW / 2, ClassBottomY);
498    fprintf (stream, "showpage SavedPage restore } def\n");
499
500    /* end of the header */
501--- 720,726 ----
502    if (GaudyFlag && Columns == 2)
503      fprintf (stream, " %li %li moveto %li -%li rlineto stroke ", LM + WW + (papermetrics->ColumnSep * SCALE / 2), StartY, 0L, StartY - EndY);
504    if (Classification != NULL)
505!       fprintf (stream, "  Classf %li %li moveto ClassString Centre 0 setgray show\n", PW / 2, ClassBottomY);
506    fprintf (stream, "showpage SavedPage restore } def\n");
507
508    /* end of the header */
509
510
511