[gnu.ghostscript.bug] Yet another fix for the Ghostscript interpreter

aida@CSL.SRI.COM (Hitoshi Aida) (05/01/89)

The BuildChar interface of the Ghostscript is not compatible with
the PostScript in that the character coordinate system is not
translated to the currentpoint.  This is a fix for it.

Hitoshi AIDA (aida@csl.sri.com)
Computer Science Laboratory, SRI International

*** gschar.c	Fri Apr 28 15:34:43 1989
--- gschar.c.org	Fri Feb 24 01:03:58 1989
***************
*** 27,33 ****
  #include "gzdevice.h"			/* must precede gxchar */
  #include "gxfont.h"
  #include "gxchar.h"
! #include "gzpath.h"			/* gxpath->gzpath 04/25/89 H.AIDA */
  #include "gzstate.h"
  
  /* Export the FontType that corresponds to */
--- 27,33 ----
  #include "gzdevice.h"			/* must precede gxchar */
  #include "gxfont.h"
  #include "gxchar.h"
! #include "gxpath.h"
  #include "gzstate.h"
  
  /* Export the FontType that corresponds to */
***************
*** 296,316 ****
  		cc->offset.y = -min(cll.y, cur.y);
  		/* Check whether the copy will succeed */
  		gx_color_render(pgs->color, pgs);
! 			/* Begin code modified by H.AIDA 04/27/89 */
! 			if ( (code = gs_gsave(pgs)) < 0 )
! 			   {	gx_unalloc_cached_char(dir, cc);
! 				return code;
! 			   }
! 			cur.x = pgs->path->position.x - pgs->ctm.tx_fixed;
! 			cur.y = pgs->path->position.y - pgs->ctm.ty_fixed;
! 			gs_moveto(pgs, (floatp)0, (floatp)0);
! 			if ( gx_copy_cached_char(pgs, cc, 0) > 0 )
! 			   {	gx_unalloc_cached_char(dir, cc);
! 				gs_grestore(pgs);
! 				return 0;
! 			   }
! 			gs_grestore(pgs);
! 			/* End code modified by H.AIDA 04/27/89 */
  		/* Nothing can go wrong now.... */
  		penum->cc = cc;
  		cc->code = gs_show_current_char(penum);
--- 296,309 ----
  		cc->offset.y = -min(cll.y, cur.y);
  		/* Check whether the copy will succeed */
  		gx_color_render(pgs->color, pgs);
! 		if ( gx_copy_cached_char(pgs, cc, 0) > 0 )
! 		   {	gx_unalloc_cached_char(dir, cc);
! 			return 0;
! 		   }
! 		if ( (code = gs_gsave(pgs)) < 0 )
! 		   {	gx_unalloc_cached_char(dir, cc);
! 			return code;
! 		   }
  		/* Nothing can go wrong now.... */
  		penum->cc = cc;
  		cc->code = gs_show_current_char(penum);
***************
*** 322,334 ****
  		pgs->device = &penum->dev_cache_dev;
  		/* Adjust the translation in the graphics context */
  		/* so that the character lines up with the cache. */
- 		    /* Modified by H.AIDA 04/27/89 */
- 		    pgs->ctm.tx = fixed2float(pgs->ctm.tx_fixed = cc->offset.x);
- 		    pgs->ctm.ty = fixed2float(pgs->ctm.ty_fixed = cc->offset.y);
- 		    pgs->inverse_valid = 0;
- 		    pgs->path->position.x = cc->offset.x + cur.x;
- 		    pgs->path->position.y = cc->offset.y + cur.y;
- 		/* Old code ....
  		   {	gs_matrix mat;
  			gs_currentmatrix(pgs, &mat);
  			mat.tx = fixed2float(cc->offset.x);
--- 315,320 ----
***************
*** 386,396 ****
  			code = gx_copy_cached_char(pgs, cc, 1);
  			if ( code < 0 ) return code;
  		   }
! 	   }	break;			/* 04/27/89 H.AIDA */
  	case sws_no_cache: ;
- 		gs_grestore(pgs);	/* 04/27/89 H.AIDA */
  	   }
! 	/* gs_grestore(pgs);		   04/27/89 H.AIDA */
  	color_loaded = 0;
  move:	if ( penum->add )
  		gs_rmoveto(pgs, penum->ax, penum->ay);
--- 372,381 ----
  			code = gx_copy_cached_char(pgs, cc, 1);
  			if ( code < 0 ) return code;
  		   }
! 	   }
  	case sws_no_cache: ;
  	   }
! 	gs_grestore(pgs);
  	color_loaded = 0;
  move:	if ( penum->add )
  		gs_rmoveto(pgs, penum->ax, penum->ay);
***************
*** 453,462 ****
  	/* Character is not cached, client must render it. */
  	if ( (code = gs_gsave(pgs)) < 0 ) return code;
  	gs_setmatrix(pgs, &pgs->char_tm);
- 	/* quick "currentpoint translate" 04/26/89 H.AIDA */
- 	pgs->ctm.tx = fixed2float(pgs->ctm.tx_fixed = pgs->path->position.x);
- 	pgs->ctm.ty = fixed2float(pgs->ctm.ty_fixed = pgs->path->position.y);
- 	pgs->inverse_valid = 0;
  	penum->width_set = sws_none;
  	penum->update = 1;
  	/* Try using the build procedure in the font. */
--- 438,443 ----