🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #2247

added backspace support to tpscript, patch included

#2247
From: Dan Judd
Date: Thu, 25 May 1989 22:29
74 lines
2813 bytes
In volume 15 of comp.sources.unix there is a ditroff to postscript package,
that also includes an ascii to postscript converter called lpscript. 
lpscript as is does not support backspaces, instead it just prints a question
mark. This causes programs that do their own underlining via the backspace
underscore method to look pretty ugly.

I modified lpscript.c to handle backspaces. Only Courier, the default font,
is handled absolutely correct because it is the only fixed-width font. The
other fonts will have some variation of effect due to the changes in width
from character to character.  

All the changes are #ifdef'd on STO

Dan Judd, St. Olaf College 5/25/1989
danjudd@thor.acc.stolaf.edu

-----------cut here for patch, your numbers may vary --------------------------
*** lpscript.org.c	Mon May 22 14:27:13 1989
--- lpscript.c	Thu May 25 16:21:42 1989
***************
*** 14,19 ****
--- 14,20 ----
  #include	<stdio.h>
  #include	"pscript.h"
  
+ #define STO
  #define	PAGEOFFSET	(1.0*PU_CM)
  #define	FONTSIZE	12.0		/* default font size (in points) */
  #define	TABSIZE		8
***************
*** 188,194 ****
--- 189,199 ----
  			putc('(', postr);
  			prefix = 1;
  		}
+ #ifdef STO
+ 		if(ch < ' ' && ch != '\b' && ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f')
+ #else
  		if(ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f')
+ #endif
  			ch = '?';
  		switch(ch)
  		{	
***************
*** 215,220 ****
--- 220,232 ----
  			fprintf(postr, ")n dpage\n");
  			prefix = 0;
  			break;
+ #ifdef STO
+ 		case '\b':
+ 			x = 0;
+ 			fprintf(postr, ")bs\n");
+ 			prefix = 0;
+ 			break;
+ #endif
  		default:
  			pch(ch);
  			x++;
***************
*** 281,286 ****
--- 293,304 ----
  	fprintf(postr, "/pgbot currentfont /FontBBox get 1 get neg 1000 div %.1f mul def\n", fontsize * aspect);
  	/* apply horizontal offset, if any */
  	fprintf(postr, "%.1f 0 translate\n", pageoffset);
+ #ifdef STO
+ 	/* figure out how big a _ is so the backspace will work right */
+ 	fprintf(postr, "/offset (_) stringwidth pop neg def\n");
+ 	/* define bs so so only 4 extra chars have to be sent for backspace*/
+ 	fprintf(postr, "/bs\n{ show\noffset 0 rmoveto\n} def");
+ #endif
  
  	/* save state */
  	endinit();
Technical Details
Message-ID: <2284@thor.acc.stolaf.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!dogie.macc.wisc.edu!indri!nic.MR.NET!thor.acc.stolaf.edu!thor.stolaf.edu!danjudd

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!dogie.macc.wisc.edu!indri!nic.MR.NET!thor.acc.stolaf.edu!thor.stolaf.edu!danjudd
From: danjudd@thor.stolaf.edu (Dan Judd)
Newsgroups: comp.sources.bugs
Subject: added backspace support to tpscript, patch included
Message-ID: <2284@thor.acc.stolaf.edu>
Date: 25 May 89 22:29:49 GMT
Sender: danjudd@thor.acc.stolaf.edu
Reply-To: danjudd@thor.stolaf.edu (Dan Judd)
Organization: St. Olaf College, Northfield, MN
Lines: 74