		Xfig-2.1.8 PS図形取り込みパッチ

  このパッチは xfig-2.1.8 において、EPS object 読み込みの機能で PS
ファイルも読み込めるようにするための非公式パッチです。
  読み込んだファイルが PS だった場合、あるいは EPS ヘッダの Boundi-
ngBox の値がおかしい場合でも正常に読み込み、キャンバスに表示できる
ようになります。
  PS ファイルには BoundingBox ヘッダーがありませんので、BoundingBox
を A4 または Letter size と見倣して処理します。A4 か Lettersize かの
選択は f_epsobj.c の先頭で、ASSUME_A4 か ASSUME_LETTER のどちらかを
#define で定義することにより行なってください。

  Export の機能を用いて PS ファイルに出力したり、印刷したりするには
同様のパッチを transfig にも当てておく必要があります。

						1994.10.30  杉本敏則
					   toshi@arcadia.genny.or.jp
					   pfd01107@niftyserve.or.jp

*** f_epsobj.c.orig	Wed Sep  1 06:18:38 1993
--- f_epsobj.c	Sat Oct 22 22:58:02 1994
***************
*** 25,30 ****
--- 25,44 ----
  #include "w_setup.h"
  #include "mode.h"
  
+ #define ASSUME_A4        /* A4 or LETTER */
+                          /* Assume the letter size or ISO A4 size 
+                             when bad value of EPS bounding box */
+ #ifdef  ASSUME_LETTER
+ #define ASSUME_PAPER    "Letter"
+ #define ASSUME_X        612
+ #define ASSUME_Y        792
+ #endif
+ #ifdef  ASSUME_A4
+ #define ASSUME_PAPER    "A4"
+ #define ASSUME_X        595
+ #define ASSUME_Y        842
+ #endif
+ 
  read_epsf(eps)
      F_eps	   *eps;
  {
***************
*** 35,41 ****
      unsigned int    hexnib;
      int		    flag;
      char	    buf[300];
!     int		    llx, lly, urx, ury, bad_bbox;
      FILE	   *epsf;
      register unsigned char *last;
  #ifdef DPS
--- 49,55 ----
      unsigned int    hexnib;
      int		    flag;
      char	    buf[300];
!     int		    llx, lly, urx, ury, bad_bbox, bad_eps, i;
      FILE	   *epsf;
      register unsigned char *last;
  #ifdef DPS
***************
*** 73,105 ****
  	file_msg("Cannot open file: %s", eps->file);
  	return 0;
      }
!     while (fgets(buf, 300, epsf) != NULL) {
! 	lower(buf);
! 	if (!strncmp(buf, "%%boundingbox", 13)) {
! 	    /* the Encapsulated PostScript Specifications (2.0) doesn't say
! 	       that the values for the bounding box must be integers */
! 	    float rllx, rlly, rurx, rury;
! 	    if (sscanf(buf, "%%%%boundingbox: %f %f %f %f",
! 		       &rllx, &rlly, &rurx, &rury) < 4) {
! 		file_msg("Bad EPS file: %s", eps->file);
! 		fclose(epsf);
! 		return 0;
! 	    }
! 	    llx = round(rllx);
! 	    lly = round(rlly);
! 	    urx = round(rurx);
! 	    ury = round(rury);
! 	    break;
  	}
      }
! 
      eps->hw_ratio = (float) (ury - lly) / (float) (urx - llx);
      eps->size_x = (urx - llx) * PIX_PER_INCH / 72.0;
      eps->size_y = (ury - lly) * PIX_PER_INCH / 72.0;
- 
-     if ( bad_bbox = ( urx <= llx || ury <= lly ) ) {
- 	file_msg("Bad values in EPS bounding box");
-     }
      bitmapz = 0;
  
  #ifdef DPS
--- 87,129 ----
  	file_msg("Cannot open file: %s", eps->file);
  	return 0;
      }
!     bad_eps = TRUE;
!     for ( i = 0; i<30; i++ ) {
!       if (fgets(buf, 300, epsf) == NULL) {
! 	break;
!       }
!       lower(buf);
!       if (!strncmp(buf, "%%boundingbox", 13)) {
! 	/* the Encapsulated PostScript Specifications (2.0) doesn't say
! 	   that the values for the bounding box must be integers */
! 	float  rllx, rlly, rurx, rury;
! 	if (sscanf(buf,"%%%%boundingbox: %f %f %f %f",
! 		   &rllx,&rlly,&rurx,&rury) == 4 ) {
! 	  bad_eps = FALSE;
  	}
+ 	llx = round(rllx);
+ 	lly = round(rlly);
+ 	urx = round(rurx);
+ 	ury = round(rury);
+ 	break;
+       }
      }
!     if (bad_eps) {
!       file_msg("Bad EPS file: %s", eps->file);
!     }
!     if ( bad_bbox = ( urx <= llx || ury <= lly ) || bad_eps ) {
! 	file_msg("Bad values in EPS bounding box (%d %d %d %d)",
! 		 llx, lly, urx, ury);
! 	llx = lly = 0;
! 	urx = ASSUME_X;
! 	ury = ASSUME_Y;
! 	bad_bbox = FALSE;
! 	file_msg("Assumed to %s size (%d %d %d %d)",
! 		 ASSUME_PAPER, llx, lly, urx, ury);
!     }
      eps->hw_ratio = (float) (ury - lly) / (float) (urx - llx);
      eps->size_x = (urx - llx) * PIX_PER_INCH / 72.0;
      eps->size_y = (ury - lly) * PIX_PER_INCH / 72.0;
      bitmapz = 0;
  
  #ifdef DPS
***************
*** 137,143 ****
      }
  #endif
      if (!bitmapz) {
!         file_msg("EPS object read OK, but no preview bitmap found/generated");
          fclose(epsf);
          return 0;
      } else if ( eps->bit_size.x <= 0 || eps->bit_size.y <= 0 ) {
--- 161,172 ----
      }
  #endif
      if (!bitmapz) {
! #ifdef GSBIT || DPS
!         file_msg
! #else
! 	put_msg
! #endif
! 	  ("EPS object read OK, but no preview bitmap found/generated");
          fclose(epsf);
          return 0;
      } else if ( eps->bit_size.x <= 0 || eps->bit_size.y <= 0 ) {
