🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #723

Official Patch 1 for Hp2pbm

#723
From: Chris Lewis
Date: Mon, 06 Jan 1992 05:07
1096 lines
28953 bytes
Archive-name: hp2pbm/patch.01
Submitted-by: clewis@ferret.ocunix.on.ca (Chris Lewis)

    This is official patch 01 for Hp2pbm.
    Please apply it by:
	cd <hp2pbm source directory>
	patch -N -p < <this file>

Michael Haws, uunet!yonder!michael, did a fair amount of work
on hp2pbm, and they comprise most of the changes in this patch.
I include his description here:

| Items that still require some work include:  All measurements should
| be kept in units of 1/3600 inches as opposed to dots (1/300).  The HPLJII uses
| 1/3600 inches as it's unit of measure.  THe HPLJII then converts this unit
| to dots (1/300) just prior to printing (see HP Technical Reference Manual).  
| 
| Fixed underlining is now supported correctly, floating underlining is yet
| to be added.
| 
| All in all I am very pleased with hp2pbm and want to thank all involved
| for their efforts.
| 
| My changes to hp2pbm include:
| 
| 	1. Left and right margins are now stored in units of dots and
| 	   not columns.  Column positions are affected by changes in
| 	   HMI, while left and right margins need to be fixed positions.
| 
| 	2. Type of clen variable was changed from short to double so 
| 	   that it could handle fractional lengths.
| 
| 	3. Left edge of the logical page is defined to be 50 dots and
| 	   is stored in LEFT_LOGICAL.  Right edge of logical page is
| 	   stored in RITE_LOGICAL.  BMX must never be less than
| 	   LEFT_LOGICAL nor greater than RITE_LOGICAL.
| 
| 	4. getcfn() now makes certain that the current font meets the 
| 	   latest font selection criteria.
| 
| 	5. Resetting text length now works correctly.
| 
| 	6. Resetting column now works correctly.
| 
| 	7. Improved method for underlining.  Still needs work.
| 	
| 	8. Added code to handle the tab character.
| 
| 	9. Carriage return now works properly.
| 
| 	10. Formfeeds now work properly.

Thank you Michael!

Further, I modified the "-r" option to permit the specification of
a pipeline.  So, for example, you can use this with psroff driving
an Epson 24 pin printer thusly:

	psroff -Tlj -t ... | hp2e24 '-r|pbm2e24' | <your spooler>


../hp2pbm.S		-r documentation, general fixups
../Makefile		added a regression test
../hpfntwrite.c		Michael's changes plus -r
../hpp.c			-r
../hptopbm.h		Version now is V1.01

Patchwrapped: 920105232033

Index: ./hp2pbm.S
*** /tmp/PATCHold/./hp2pbm.S	Sun Jan  5 23:18:30 1992
--- ./hp2pbm.S	Sun Jan  5 23:18:31 1992
***************
*** 1,4 ****
! .\"Copyright 1989, 1990, 1991 by Chris Lewis 1.1 91/12/03
  .TH HP2PBM %%MANEXT%% "standalone"
  .SH NAME
  hp2pbm,hp2hifax,hp2lofax,hp2sun,hp2e24 \- Translate HPLJ codes to to Postscript or PBM
--- 1,4 ----
! .\"Copyright 1989, 1990, 1991 by Chris Lewis 1.2 92/01/05
  .TH HP2PBM %%MANEXT%% "standalone"
  .SH NAME
  hp2pbm,hp2hifax,hp2lofax,hp2sun,hp2e24 \- Translate HPLJ codes to to Postscript or PBM
***************
*** 14,21 ****
  .SH DESCRIPTION
  The
  .B hp2pbm
! program (linked to any of its aliases) is a program that interprets HP PCL (Hewlett Packard Printer Control
! Language - the language of HP Laserjets)
  escape code sequences.
  .B Hp2pbm
  can then generate an english description of the codes, translate the input
--- 14,21 ----
  .SH DESCRIPTION
  The
  .B hp2pbm
! program (linked to any of its aliases) is a program that interprets HP PCL
! (Hewlett Packard Printer Control Language - the language of HP Laserjets)
  escape code sequences.
  .B Hp2pbm
  can then generate an english description of the codes, translate the input
***************
*** 31,37 ****
  that has been extended to optionally emit PBM.
  .B Hpinterp
  is a part of
! .BR psroff 
  This can be considered to be an ``after market'' optional upgrade
  to
  .BR psroff .
--- 31,37 ----
  that has been extended to optionally emit PBM.
  .B Hpinterp
  is a part of
! .BR psroff .
  This can be considered to be an ``after market'' optional upgrade
  to
  .BR psroff .
***************
*** 48,56 ****
  .BR CorelDraw ,
  including (some) built in and all downloaded fonts (except
  compressed ones) and including built in and downloaded graphics and rasters.
! hp2pbm can be used to drive a number of different configurations, such as
  Postscript printers, Klaus Schallhorn's
! .B faxpak 
  (to transmit faxes using a fax modem),
  or other devices using PBM converters, such as Epson 24 pin printers,
  Sun displays, 3b1 consoles etc.
--- 48,57 ----
  .BR CorelDraw ,
  including (some) built in and all downloaded fonts (except
  compressed ones) and including built in and downloaded graphics and rasters.
! .B Hp2pbm
! can be used to drive a number of different configurations, such as
  Postscript printers, Klaus Schallhorn's
! .B faxpak
  (to transmit faxes using a fax modem),
  or other devices using PBM converters, such as Epson 24 pin printers,
  Sun displays, 3b1 consoles etc.
***************
*** 68,74 ****
  option tells
  .B hp2pbm
  to emit Postscript to standard output.
! (Specifying both \-v and \-p at the same time is rather confusing)
  Note: unless
  .B hp2pbm
  is used with the rest of the
--- 69,75 ----
  option tells
  .B hp2pbm
  to emit Postscript to standard output.
! Specifying both \-v and \-p at the same time is rather confusing.
  Note: unless
  .B hp2pbm
  is used with the rest of the
***************
*** 90,102 ****
  .BI f n
  where \f2n\fP is the HP PCL font ID number.
  The ``FONTS'' directory should be created manually before running
! .B hp2pbm.
  A file called
  .BI f n .desc
  is also created in the ``FONTS'' directory, which contains a description of
  each character.
  If the \-c option is specified, an ASCII drawing will be made
! of each glyph in the font in the 
  .B .desc
  file.
  This is very useful for examining HP PCL fonts, whether they are
--- 91,103 ----
  .BI f n
  where \f2n\fP is the HP PCL font ID number.
  The ``FONTS'' directory should be created manually before running
! .B hp2pbm .
  A file called
  .BI f n .desc
  is also created in the ``FONTS'' directory, which contains a description of
  each character.
  If the \-c option is specified, an ASCII drawing will be made
! of each glyph in the font in the
  .B .desc
  file.
  This is very useful for examining HP PCL fonts, whether they are
***************
*** 106,115 ****
  .BI \-r value
  option is specified,
  .B hp2pbm
! (hp2??fax and hp2e24) 
! creates PBM files. The associated argument is
! the basename for the generated files.
  The first page is named ``value.0'', second ``value.1'' etc.
  The \-d option specifies a resolution not automatically assumed
  from argv[0].
  It is specified as
--- 107,130 ----
  .BI \-r value
  option is specified,
  .B hp2pbm
! (hp2??fax and hp2e24) creates PBM files.
! The associated argument is the basename for the generated files.
  The first page is named ``value.0'', second ``value.1'' etc.
+ If
+ .I value
+ has a pipe symbol (``|'') as the first character, the rest
+ .I value
+ is used as a pipeline to send each page.
+ Hence, for example, you can use
+ .B hp2pbm
+ with psroff like so:
+ .sp
+ .nf
+ .in +1i
+ psroff -Tlj -t file | hp2e24 '-r|pbm2e24' | lp
+ .in -1i
+ .fi
+ .P
  The \-d option specifies a resolution not automatically assumed
  from argv[0].
  It is specified as
***************
*** 145,160 ****
  Hewlett Packard Laserjet documentation.
  Adobe Systems Postscript documentation.
  .SH WARNINGS
- .B Hp2pbm's 
- handling of downloaded macros is not fully tested. 
- Compressed fonts (Laserjet II) and scalable built in fonts (Laserjet 
- III) are not supported. Except for these limitations
- .B Hp2pbm
- should be fully compatible with Laserjet II printers. 
  .P
! PBM file sizes are resolution dependent (legal size or A4 paper 
! at 300DPI: as much as 1.2Mb for each page).
  .P
  The
  .B \-p
  option was implemented soley as a test jig for the HP PCL output
--- 160,179 ----
  Hewlett Packard Laserjet documentation.
  Adobe Systems Postscript documentation.
  .SH WARNINGS
  .P
! .B "Hp2pbm output can be huge!"
! PBM file sizes are resolution dependent.
! At 300DPI a legal size sheet is 1.2 megabytes
! .B "PER PAGE" !
  .P
+ .B "Hp2pbm's"
+ handling of downloaded macros is not fully tested.
+ Compressed fonts (Laserjet II) and scalable built in fonts (Laserjet
+ III) are not supported.
+ Except for these limitations
+ .B Hp2pbm
+ should be fully compatible with Laserjet II printers.
+ .P
  The
  .B \-p
  option was implemented soley as a test jig for the HP PCL output
***************
*** 164,174 ****
  The Postscript generating code isn't complete, but this will
  probably be rectified in future.
  .P
! .B Hp2ps
  will not create a FONTS directory if one doesn't exist, and will die if
  there isn't one.
! .PP
! .B "Hp2ps \-p"
  will attempt to do something sane with selecting a font by characteristic,
  but be warned, these use the printer's built-in fonts (which are likely
  to be radically different from a LJ's), so the widths may be different and
--- 183,193 ----
  The Postscript generating code isn't complete, but this will
  probably be rectified in future.
  .P
! .B Hp2pbm
  will not create a FONTS directory if one doesn't exist, and will die if
  there isn't one.
! .P
! .B "Hp2pbm \-p"
  will attempt to do something sane with selecting a font by characteristic,
  but be warned, these use the printer's built-in fonts (which are likely
  to be radically different from a LJ's), so the widths may be different and
Index: ./Makefile
*** /tmp/PATCHold/./Makefile	Sun Jan  5 23:18:40 1992
--- ./Makefile	Sun Jan  5 23:18:41 1992
***************
*** 1,4 ****
! # Makefile for hptopbm standalone release 1.2 91/12/03
  
  #	Configuration:
  
--- 1,4 ----
! # Makefile for hptopbm standalone release 1.3 92/01/05
  
  #	Configuration:
  
***************
*** 61,74 ****
  		@chmod 444 $@
  
  # components
! mem.o:		mem.c
! 		$(CC) -c $(CFLAGS) mem.c
  
! hpp.o:		hptopbm.h hpp.c
! 		$(CC) -c $(CFLAGS) hpp.c
  
  hpfntwrite.o:	hptopbm.h hpfntwrite.c
! 		$(CC) -c $(CFLAGS) hpfntwrite.c
  
  pbm2e24:	pbm2e24.o mem.o
  		$(CC) $(CFLAGS) -o pbm2e24 pbm2e24.o mem.o $(LIBFLAGS)
--- 61,74 ----
  		@chmod 444 $@
  
  # components
! #mem.o:		mem.c
! #		$(CC) -c $(CFLAGS) mem.c
  
! hpp.o:		hptopbm.h # hpp.c
! #		$(CC) -c $(CFLAGS) hpp.c
  
  hpfntwrite.o:	hptopbm.h hpfntwrite.c
! #		$(CC) -c $(CFLAGS) hpfntwrite.c
  
  pbm2e24:	pbm2e24.o mem.o
  		$(CC) $(CFLAGS) -o pbm2e24 pbm2e24.o mem.o $(LIBFLAGS)
***************
*** 78,88 ****
--- 78,95 ----
  
  $(LIBFILES):
  		uudecode < $@.UU
+ 		chmod 444 $@
  
  myuid:
  		echo 'main() { printf("%d%c", getuid(), 10); exit(0); }' > myuid.c
  		$(CC) -o myuid myuid.c
  		rm -f myuid.c
+ 
+ regression:	hp2pbm
+ 		psroff -t -Tlj testdoc > /tmp/testdoc.lj
+ 		./hp2pbm -r/tmp/new -d80,80 < /tmp/testdoc.lj
+ 		$(BINDIR)/hp2pbm -r/tmp/old -d80,80 < /tmp/testdoc.lj
+ 		./hp2pbm '-r|pbm2e24' -d80,80 > /tmp/pipe < /tmp/testdoc.lj
  
  install:	hp2pbm myuid
  		test "`./myuid`" = 0 || \
Index: ./hpfntwrite.c
*** /tmp/PATCHold/./hpfntwrite.c	Sun Jan  5 23:18:51 1992
--- ./hpfntwrite.c	Sun Jan  5 23:18:55 1992
***************
*** 18,24 ****
  #include "hptopbm.h"
  
  #ifndef	lint
! char SCCSid[] = "@(#)hpfntwrite.c: 1.1 91/12/03 00:34:42";
  #endif
  
  #ifdef	FAXPAK
--- 18,24 ----
  #include "hptopbm.h"
  
  #ifndef	lint
! char SCCSid[] = "@(#)hpfntwrite.c: 1.3 92/01/05 23:16:27";
  #endif
  
  #ifdef	FAXPAK
***************
*** 66,72 ****
  		dpi,
  		pID,
  		top_dots,
- 		left_dots,
  		text_len;
  	double	hmi,
  		lhite,
--- 66,71 ----
***************
*** 118,124 ****
  
  struct	CHAR_BITMAP
  {
! 	short len, hite, clen, toffs, loffs;
  	uchar **CH;
  };
  
--- 117,124 ----
  
  struct	CHAR_BITMAP
  {
! 	short len, hite, toffs, loffs;
! 	double clen;
  	uchar **CH;
  };
  
***************
*** 214,226 ****
  	lpi = 6.0;
  	orgenv.page_len = PAGE_LEN;
  	orgenv.top_margin = new_topmargin = TOP_MARGIN;
! 	orgenv.left_margin = LEFT_MARGIN;
! 	orgenv.rite_margin = RITE_MARGIN;
  	orgenv.text_len = PAGE_LEN - TOP_MARGIN;
  	orgenv.text_len -= 3;
  	orgenv.lhite = 50;
  	orgenv.top_dots = fax_head_size + orgenv.top_margin*orgenv.lhite;
- 	orgenv.left_dots = 47;	/* dots = .157 in */
  	orgenv.dpi = 75;	/* hp 2686a */
  	stackpos = 0;
  	try_select = 0;
--- 214,225 ----
  	lpi = 6.0;
  	orgenv.page_len = PAGE_LEN;
  	orgenv.top_margin = new_topmargin = TOP_MARGIN;
! 	orgenv.left_margin = LEFT_LOGICAL;
! 	orgenv.rite_margin = RITE_LOGICAL;
  	orgenv.text_len = PAGE_LEN - TOP_MARGIN;
  	orgenv.text_len -= 3;
  	orgenv.lhite = 50;
  	orgenv.top_dots = fax_head_size + orgenv.top_margin*orgenv.lhite;
  	orgenv.dpi = 75;	/* hp 2686a */
  	stackpos = 0;
  	try_select = 0;
***************
*** 257,263 ****
  		{
  			cf = &hf->chars[i];
  			cf->CH = (uchar **)NULL;
! 			cf->len = cf->hite = cf->clen = cf->toffs = cf->loffs = 0;
  		}
  	}
  	hf = &hpfonts[LINEPRINTER];
--- 256,263 ----
  		{
  			cf = &hf->chars[i];
  			cf->CH = (uchar **)NULL;
! 			cf->len = cf->hite = cf->toffs = cf->loffs = 0;
! 			cf->clen = 0;
  		}
  	}
  	hf = &hpfonts[LINEPRINTER];
***************
*** 302,308 ****
  xyinit()
  {
  	BMY = orgenv.top_dots;
! 	BMX = 0.0;
  	GRAPHX = 0.0;
  }
  ovlyinit()
--- 302,308 ----
  xyinit()
  {
  	BMY = orgenv.top_dots;
! 	BMX = LEFT_LOGICAL;
  	GRAPHX = 0.0;
  }
  ovlyinit()
***************
*** 420,430 ****
  end_bitmap(tname)
  char *tname;
  {
! 	int i, j, xmax;
  	FILE *fp;
  
! 	if ((fp = fopen(tname, "w")) == NULL)
! 		die("cannot create pbm file %s\n",tname);
  
  	ymax_used = yscale[max_ln-1];
  #ifdef	FAXPAK
--- 420,438 ----
  end_bitmap(tname)
  char *tname;
  {
! 	int i, j, xmax, pipe;
  	FILE *fp;
  
! 	if (tname[0] == '|') {
! 	    fp = popen(tname+1, "w");
! 	    pipe = 1;
! 	} else {
! 	    fp = fopen(tname, "w");
! 	    pipe = 0;
! 	}
! 
! 	if (fp == NULL)
! 		die("cannot create pbm file `%s'\n",tname);
  
  	ymax_used = yscale[max_ln-1];
  #ifdef	FAXPAK
***************
*** 442,448 ****
  				j,xmax,i,ymax_used);
  		(void)memset((char*)block[i], '\0', xmax);
  	}
! 	fclose(fp);
  
  	ymax_used = xmax_used = 0;
  	orgenv.top_margin = new_topmargin;
--- 450,460 ----
  				j,xmax,i,ymax_used);
  		(void)memset((char*)block[i], '\0', xmax);
  	}
! 	if (pipe) {
! 	    if (pclose(fp))
! 		die("Pipe failure in `%s'\n", tname);
! 	} else
! 	    fclose(fp);
  
  	ymax_used = xmax_used = 0;
  	orgenv.top_margin = new_topmargin;
***************
*** 458,463 ****
--- 470,477 ----
  {
  	struct HPFONT *hpf;
  
+ 	if (try_select)
+ 		best_match();
  	if (curenv->cur_fnt < 0 || curenv->cur_fnt >= MAX_FONT)
  		die("don't know font %d\n",curenv->cur_fnt);
  	hpf = &hpfonts[curenv->cur_fnt];
***************
*** 492,500 ****
  }
  lr_default()
  {
! 	curenv->left_margin = LEFT_MARGIN;
! 	curenv->left_dots = 47;
! 	curenv->rite_margin = RITE_MARGIN;
  }
  hmi_default()
  {
--- 506,513 ----
  }
  lr_default()
  {
! 	curenv->left_margin = LEFT_LOGICAL;
! 	curenv->rite_margin = RITE_LOGICAL;
  }
  hmi_default()
  {
***************
*** 526,532 ****
  	if (cptr->CH)
  		free((char*)cptr->CH);
  	cptr->CH = (uchar **)NULL;
! 	cptr->len = cptr->hite = cptr->clen = cptr->toffs = cptr->loffs = 0;
  }
  clear1font(fptr)
  struct HPFONT *fptr;
--- 539,546 ----
  	if (cptr->CH)
  		free((char*)cptr->CH);
  	cptr->CH = (uchar **)NULL;
! 	cptr->len = cptr->hite = cptr->toffs = cptr->loffs = 0;
! 	cptr->clen = 0;
  }
  clear1font(fptr)
  struct HPFONT *fptr;
***************
*** 702,708 ****
  rs_tlen(n)
  double n;
  {
! 	if (n && (n <= (curenv->page_len - curenv->top_margin)))
  		curenv->text_len = (int)n;
  	else if (!n)
  		tlen_default();
--- 716,722 ----
  rs_tlen(n)
  double n;
  {
! 	if (n && (n * curenv->lhite <= (PAGE_LEN*50) - curenv->top_dots - 150))
  		curenv->text_len = (int)n;
  	else if (!n)
  		tlen_default();
***************
*** 711,720 ****
  double n;
  {
  	cfn = getcfn();
! 	if (n < curenv->rite_margin)
  	{
! 		curenv->left_margin = (int)n;
! 		curenv->left_dots = curenv->left_margin * cfn->space_len;
  	}
  }
  rs_mright(n)
--- 725,735 ----
  double n;
  {
  	cfn = getcfn();
! 	if (LEFT_LOGICAL + (n * cfn->space_len) < curenv->rite_margin)
  	{
! 		curenv->left_margin = n * cfn->space_len + LEFT_LOGICAL;
! 		if (BMX < curenv->left_margin)
! 			BMX = curenv->left_margin;
  	}
  }
  rs_mright(n)
***************
*** 728,739 ****
  {
  	cfn = getcfn();
  	if (relative())
! 		BMX += n*cfn->space_len;
! 	else if (!(int)n)
! 		BMX = curenv->left_dots;
! 	else BMX = n*cfn->space_len;
! 	BMX = max(0.0, BMX);
! 	BMX = min(BMX, (double)((RITE_MARGIN-1)*30));	/* using 10cpi for max */
  }
  rs_row(n)
  double n;
--- 743,752 ----
  {
  	cfn = getcfn();
  	if (relative())
! 		BMX = ((int)(BMX * 12) + (int)(n*cfn->space_len*12)) / 12.0;
! 	else BMX = LEFT_LOGICAL + n*cfn->space_len;
! 	BMX = max(LEFT_LOGICAL,BMX);
! 	BMX = min(BMX, RITE_LOGICAL);
  }
  rs_row(n)
  double n;
***************
*** 744,750 ****
  	{
  		curenv->top_margin = new_topmargin;
  		curenv->top_dots = fax_head_size + curenv->top_margin*curenv->lhite;
! 		BMY = (double)curenv->top_dots * curenv->lhite;
  		return;
  	}
  	if (relative())
--- 757,763 ----
  	{
  		curenv->top_margin = new_topmargin;
  		curenv->top_dots = fax_head_size + curenv->top_margin*curenv->lhite;
! 		BMY = (double)curenv->top_dots;
  		return;
  	}
  	if (relative())
***************
*** 757,763 ****
--- 770,779 ----
  			return;
  		}
  		else if (BMY < 0)
+ /*
  			BMY = curenv->top_dots * curenv->lhite;
+ */
+ 			BMY = curenv->top_dots;
  	}
  	else
  		BMY = curenv->top_dots + n * curenv->lhite;
***************
*** 811,822 ****
  double x;
  {
  	if (relative())
! 		BMX += x;
  	else BMX = x;
! 	BMX = max(0.0, BMX);
  			/* max == rightmost legal pixel */
! 			/* would be pixel 29 if RIGHT_MARGIN == 0 */
! 	BMX = min(BMX, (double)((1+RITE_MARGIN)*30)-1);	
  }
  rs_Y(y,decipt)
  double y;
--- 827,837 ----
  double x;
  {
  	if (relative())
! 		BMX = ((int)(BMX * 12) + (int)(x * 12)) / 12.0;
  	else BMX = x;
! 	BMX = max(LEFT_LOGICAL, BMX);
  			/* max == rightmost legal pixel */
! 	BMX = min(BMX, RITE_LOGICAL);	
  }
  rs_Y(y,decipt)
  double y;
***************
*** 836,853 ****
  int set;
  {
  	lastspec.symset = set;
  }
  rs_spacing(n)
  int n;
  {
- 	cfn = getcfn();
- 	cfn->prop_spaced = n;
- 	if (cfn->real_spaced)
- 	{
- 		cfn->space_len = cfn->real_space_len;
- 		curenv->hmi = cfn->real_space_len;
- 	}
  	lastspec.prop_spaced = n;
  }
  rs_pitch(n)
  double n;
--- 851,863 ----
  int set;
  {
  	lastspec.symset = set;
+ 	try_select = 1;
  }
  rs_spacing(n)
  int n;
  {
  	lastspec.prop_spaced = n;
+ 	try_select = 1;
  }
  rs_pitch(n)
  double n;
***************
*** 893,899 ****
  rs_ul(n)
  double n;
  {
! 	curenv->underline = (int)n;
  }
  rs_thru(n)
  double n;
--- 903,914 ----
  rs_ul(n)
  double n;
  {
! 	curenv->underline = 1;		/* can't handle floating yet */
! }
! rs_ul_off(n)
! double n;
! {
! 	curenv->underline = 0;
  }
  rs_thru(n)
  double n;
***************
*** 1052,1059 ****
  		cbm->len = width/8 + 1;
  	else cbm->len = width/8;
  	cbm->hite = hite;
! 	if ((cbm->clen = delta/4) == 0)
! 		cbm->clen = 8*cbm->len;	/* yes, I do have some strange fonts */
  
  	if (!cf->prop_spaced && c == 'x' && (!cf->chars[' '].clen))
  		cf->space_len = cbm->clen;
--- 1067,1075 ----
  		cbm->len = width/8 + 1;
  	else cbm->len = width/8;
  	cbm->hite = hite;
! 	cbm->clen = delta/4.0;
! 	if (cbm->clen == 0)
! 		cbm->clen = 8.0*cbm->len;	/* yes, I do have some strange fonts */
  
  	if (!cf->prop_spaced && c == 'x' && (!cf->chars[' '].clen))
  		cf->space_len = cbm->clen;
***************
*** 1228,1235 ****
--- 1244,1255 ----
  	if (k < 0 || k >= MAX_PAT)
  		k = SOLID;
  
+ /*
  	bmx = (int)(BMX + .5);
  	bmy = (int)(BMY + .5);
+ */
+ 	bmx = BMX;
+ 	bmy = BMY;
  	hlen = (int)(curenv->Hlen + .5);
  	vlen = (int)(curenv->Vlen + .5);
  
***************
*** 1265,1271 ****
  int c;
  {
  	struct CHAR_BITMAP *cbm, *ubm;
! 	int i, j, k, curx, cury, localy, clen, before;
  
  	if (see_thru)
  		return;
--- 1285,1292 ----
  int c;
  {
  	struct CHAR_BITMAP *cbm, *ubm;
! 	int i, j, k, curx, cury, localy, before,startx,endx,curcol,newcol;
! 	double clen;
  
  	if (see_thru)
  		return;
***************
*** 1275,1282 ****
  
  	switch(c)
  	{
  	case 0x0a:	rs_row(1.0);		return;
! 	case 0x0d:	rs_col((double)curenv->left_margin);	return;
  	case 0x0e:	setshift(SECONDARY);	return;
  	case 0x0f:	setshift(PRIMARY);	return;
  	}
--- 1296,1308 ----
  
  	switch(c)
  	{
+ 	case 0x09:	curcol = (BMX - curenv->left_margin) / cfn->space_len;
+ 			newcol = ((curcol + 8) / 8) * 8.0;
+ 			rs_X((double)curenv->left_margin + 
+ 				newcol * cfn->space_len);
+ 				return;
  	case 0x0a:	rs_row(1.0);		return;
! 	case 0x0d:	rs_X((double)curenv->left_margin);	return;
  	case 0x0e:	setshift(SECONDARY);	return;
  	case 0x0f:	setshift(PRIMARY);	return;
  	}
***************
*** 1293,1300 ****
  	if ((!cbm->len) && c != ' ' && c != '\b')
  		return;
  
! 	bmx = (int)(BMX + .5);
! 	bmy = (int)(BMY + .5);
  	if (bmx + clen + cbm->loffs >= max_col)
  		return;
  	cury = bmy - cbm->toffs;
--- 1319,1328 ----
  	if ((!cbm->len) && c != ' ' && c != '\b')
  		return;
  
! 	bmx = (int)BMX;		/* positions should be truncated not rounded */
! 	bmy = (int)BMY;
! 	startx = bmx;
! 
  	if (bmx + clen + cbm->loffs >= max_col)
  		return;
  	cury = bmy - cbm->toffs;
***************
*** 1319,1325 ****
  
  	if (c > ' ')
  	{
! 		BMX += (double)clen;
  		ymax_used = max(ymax_used,yscale[cury + cbm->hite]);
  		xmax_used = max(xmax_used,xscale[curx]);
  	}
--- 1347,1353 ----
  
  	if (c > ' ')
  	{
! 		BMX = ((int)(BMX * 12) + (int)(clen * 12)) / 12.0;
  		ymax_used = max(ymax_used,yscale[cury + cbm->hite]);
  		xmax_used = max(xmax_used,xscale[curx]);
  	}
***************
*** 1326,1350 ****
  	else
  	{
  		if (c != '\b')
! 			BMX += (double)clen;
! 		else BMX -= (double)clen;
  		xmax_used = max(xmax_used,xscale[bmx]);
  	}
  
  	if (curenv->underline)
  	{
! 		int after = curx;
! 
! 		ubm = &cfn->chars['_'];
! 		for (i=0; i<cbm->hite; i++)
  		{
! 			curx = before;
! 			localy = yscale[cury+i];
! 
! 			for (j=0; curx<after; )
! 				for (k=0; k<8 && curx<after; k++,curx++)
! 					if (ubm->CH[i][j] & bit[k])
! 						setpix(localy,xscale[curx]);
  		}
  	}
  	dotted = TRUE;
--- 1354,1373 ----
  	else
  	{
  		if (c != '\b')
! 			BMX = ((int)(BMX * 12) + (int)(clen * 12)) / 12.0;
! 		else BMX = ((int)(BMX * 12) - (int)(clen * 12)) / 12.0;
  		xmax_used = max(xmax_used,xscale[bmx]);
  	}
  
  	if (curenv->underline)
  	{
! 		endx = BMX;
! 		for (i = 5; i < 8 ; i++)		/* fixed underlining */
  		{
! 			curx = startx;
! 			localy = yscale[bmy+i];
! 			for (j=0; curx<endx ; curx++)
! 				setpix(localy,xscale[curx]);
  		}
  	}
  	dotted = TRUE;
Index: ./hpp.c
*** /tmp/PATCHold/./hpp.c	Sun Jan  5 23:19:27 1992
--- ./hpp.c	Sun Jan  5 23:19:33 1992
***************
*** 21,27 ****
  
  #ifndef	lint
  static char SCCSID[] =
!     "@(#)hpp.c 1.2 91/12/04 04:03:57";
  #endif
  
  #include "hptopbm.h"
--- 21,27 ----
  
  #ifndef	lint
  static char SCCSID[] =
!     "@(#)hpp.c 1.4 92/01/05 23:16:48";
  #endif
  
  #include "hptopbm.h"
***************
*** 157,163 ****
  int	rs_lpi(), rs_plen(), rs_mtop(),
  	create_fnthdr(), rs_dpi(), rs_graphxy(),
  	rs_pitch(), rs_tlen(), rs_mleft(), rs_mright(),
! 	rs_vmi(), rs_row(), rs_col(), rs_ul(), rs_thru(),
  	rs_hmi(), rs_lterm(), rs_setpitch(),
  	rs_fc_ctl(), rs_stack(), rs_hsize(), rs_hdsize(),
  	rs_vsize(), rs_vdsize(), rs_pid(), rs_prnpat();
--- 157,163 ----
  int	rs_lpi(), rs_plen(), rs_mtop(),
  	create_fnthdr(), rs_dpi(), rs_graphxy(),
  	rs_pitch(), rs_tlen(), rs_mleft(), rs_mright(),
! 	rs_vmi(), rs_row(), rs_col(), rs_ul(), rs_ul_off(), rs_thru(),
  	rs_hmi(), rs_lterm(), rs_setpitch(),
  	rs_fc_ctl(), rs_stack(), rs_hsize(), rs_hdsize(),
  	rs_vsize(), rs_vdsize(), rs_pid(), rs_prnpat();
***************
*** 201,207 ****
      {"&aH",	"Move to Column (Decipoints)",NULL,movedx },
      {"&aV",	"Move to Row (Decipoints)",NULL,movedy },
      {"&dD",	"Underline on",		NULL,	NULL,	rs_ul },
!     {"&d@",	"Underline off",	NULL,	NULL,	rs_ul },
      {"&pX",	"Transparent Print",	NULL,	NULL,	rs_thru },
      {"&lL",	"Perf Skip", 		pscont },
      {"&kH",	"HMI",			NULL,	NULL,	rs_hmi },
--- 201,207 ----
      {"&aH",	"Move to Column (Decipoints)",NULL,movedx },
      {"&aV",	"Move to Row (Decipoints)",NULL,movedy },
      {"&dD",	"Underline on",		NULL,	NULL,	rs_ul },
!     {"&d@",	"Underline off",	NULL,	NULL,	rs_ul_off },
      {"&pX",	"Transparent Print",	NULL,	NULL,	rs_thru },
      {"&lL",	"Perf Skip", 		pscont },
      {"&kH",	"HMI",			NULL,	NULL,	rs_hmi },
***************
*** 827,834 ****
  		if (c == '\n')
  		    movetype = RELATIVE;
  
! 		if (c == '\f')
  		    pbmeject(TRUE);
  		else prt_hpchr(c);
  		movetype = ABSOLUTE;
  	    }
--- 827,836 ----
  		if (c == '\n')
  		    movetype = RELATIVE;
  
! 		if (c == '\f') {
  		    pbmeject(TRUE);
+ 		    rs_row(0.0);
+ 		}
  		else prt_hpchr(c);
  		movetype = ABSOLUTE;
  	    }
***************
*** 841,846 ****
--- 843,850 ----
  movex(num)
  double num; {
      curX = num;
+     if (movetype == ABSOLUTE)
+ 	curX += LEFT_LOGICAL;
      if (rast)
  	rs_X(curX);
      if (genps)
***************
*** 859,864 ****
--- 863,870 ----
  movedx(num)
  double num; {
      curX = num * 300.0 / 720.0;
+     if (movetype == ABSOLUTE)
+ 	curX += LEFT_LOGICAL;
      if (rast)
  	rs_X(curX);
      if (genps)
***************
*** 1005,1011 ****
  int inc; {
      int (*old_func)();
  
!     sprintf(pbmtname,"%s.%d",pbmname,pbmpage);
      pbmpage += inc;
      if (have_auto_macro > -1) {
  	old_func = getchar_func;
--- 1011,1020 ----
  int inc; {
      int (*old_func)();
  
!     if (pbmname[0] == '|')
! 	strcpy(pbmtname, pbmname);
!     else
! 	sprintf(pbmtname,"%s.%d",pbmname,pbmpage);
      pbmpage += inc;
      if (have_auto_macro > -1) {
  	old_func = getchar_func;
Index: ./hptopbm.h
*** /tmp/PATCHold/./hptopbm.h	Sun Jan  5 23:20:12 1992
--- ./hptopbm.h	Sun Jan  5 23:20:19 1992
***************
*** 16,25 ****
  	Canada K0A 1T0
  	(613) 832-0541
  
! 	Function: Header file for hp2pbm.  1.1 91/12/03 00:34:41
   */
  
! #define	VERSION	"hp2pbm V1.00"
  
  #include <stdio.h>
  #include <ctype.h>
--- 16,25 ----
  	Canada K0A 1T0
  	(613) 832-0541
  
! 	Function: Header file for hp2pbm.  1.3 92/01/05 23:17:02
   */
  
! #define	VERSION	"hp2pbm V1.01"
  
  #include <stdio.h>
  #include <ctype.h>
***************
*** 51,56 ****
--- 51,57 ----
  
  #define	TOP_MARGIN	3	/* half inch, 300/6lpi = 3 lines */
  #define	LEFT_MARGIN	0	/* char column pos, not dots */
+ #define LEFT_LOGICAL    50
  
  /* CONFIG: if !A4, define your default paper size (A4/LETTER are best for fax) */
  #if	(!A4) && (!LETTER) && (!LEGAL) && (!B5)
***************
*** 60,80 ****
--- 61,85 ----
  #if	LETTER
  #define	PAGE_LEN	66
  #define	RITE_MARGIN	80
+ #define RITE_LOGICAL	LEFT_LOGICAL+2400
  #endif
  
  #if	A4
  #define	PAGE_LEN	70
  #define	RITE_MARGIN	77
+ #define RITE_LOGICAL	LEFT_LOGICAL+2338
  #endif
  
  #if	LEGAL
  #define	PAGE_LEN	84
  #define	RITE_MARGIN	80
+ #define RITE_LOGICAL	LEFT_LOGICAL+2400
  #endif
  
  #if	B5
  #define	PAGE_LEN	60
  #define	RITE_MARGIN	66
+ #define RITE_LOGICAL	LEFT_LOGICAL+2400	/* dont know about B5's */
  #endif
  
  #define	PRIMARY		1
-- 
Chris Lewis; clewis@ferret.ocunix.on.ca; Phone: Canada 613 832-0541
Psroff 3.0 info: psroff-request@ferret.ocunix.on.ca
Moderator of the ferret list: ferret-request@ferret.ocunix.on.ca
**** NEVER let something mechanical know you're in a hurry. ****
Technical Details
Message-ID: <2987@ecicrl.ocunix.on.ca>
Path: arc1-ca.pugleaf.net!wupost!cs.utexas.edu!utgpu!cunews!micor!ecicrl!clewis

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!cs.utexas.edu!utgpu!cunews!micor!ecicrl!clewis
From: clewis@ferret.ocunix.on.ca (Chris Lewis)
Newsgroups: comp.sources.bugs,alt.sources
Subject: Official Patch 1 for Hp2pbm
Message-ID: <2987@ecicrl.ocunix.on.ca>
Date: 6 Jan 92 05:07:20 GMT
Followup-To: comp.sources.bugs
Organization: Elegant Communications Inc., Ottawa, Canada
Lines: 1096