Path: galaxy.trc.rwcp.or.jp!news.trc!nf2.iij.ad.jp!nr0.iij.ad.jp!news.iij.ad.jp!rim.or.jp!Q.T.Honey!news.hbl.or.jp!cage1.hamster.ne.jp!nf2.spnet.ne.jp!news.cs.ritsumei.ac.jp!odins-suita!itserv.it.okayama-u.ac.jp!not-for-mail
From: Hiroto Kagotani <kagotani@in.it.okayama-u.ac.jp>
Newsgroups: fj.sources,fj.archives.programs.sources,fj.comp.texhax
Subject: dvipsk patch for epsf.sty/epsbox.sty
Followup-To: fj.comp.texhax
Date: 24 Mar 1998 14:55:19 +0900
Organization: Dept. of Information Technology, Okayama University, Japan
Lines: 171
Message-ID: <7xpvjctyyg.fsf@in.it.okayama-u.ac.jp>
NNTP-Posting-Host: loach.in.it.okayama-u.ac.jp
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: text/plain; charset=ISO-2022-JP
X-Newsreader: Gnus v5.5/Emacs 20.2
Xref: galaxy.trc.rwcp.or.jp fj.sources:4823 fj.archives.programs.sources:31 fj.comp.texhax:10321
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.comp.texhax&nb=10321&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

dvipsk-5.66a $B$G!"(Bdvi2ps-j $BMQ$N(B epsf.sty $B$H(B jdvi2kps $BMQ$N(B epsbox.sty $B$,(B
$B@8@.$9$k(B \special $B$r2r<a$G$-$k$h$&$K$9$k$?$a$N%Q%C%A$G$9!#(B

$B$3$s$J%Q%C%A$r:n$C$F$$$k?M$O$?$/$5$s$$$i$C$7$c$k$H;W$$$^$9$,!"(B
$B<j85$K$J$+$C$?$N$G:n$j$^$7$?!#(B

pTeX $B$H$$$C$7$g$KG[I[$5$l$F$$$k(B jpatch-p1.3b $B$H$OFHN)$KEv$F$k$3$H$,$G(B
$B$-$^$9!#(B

$BL5J]>Z!"Cx:n8"J|4~$G$9!#(B
--
$BdFC+M5?M(B <kagotani@in.it.okayama-u.ac.jp>

--- ../dvipsk-5.66a/dvipsk/dospecial.cMon Jan 20 03:04:26 1997
+++ dvipsk/dospecial.cTue Mar 24 14:30:26 1998
@@ -143,6 +143,54 @@
    }
 }
 
+static void
+fgetboundingbox(f, llx_p, lly_p, urx_p, ury_p)
+char *f;
+float *llx_p;
+float *lly_p;
+float *urx_p;
+float *ury_p;
+{
+    FILE *fp;
+    char buf[BUFSIZ];
+    fp = search(figpath, f, READ);
+    if (fp == 0)
+fp = search(headerpath, f, READ);
+    if (fp) {
+while (fgets(buf, BUFSIZ, fp) != 0) {
+    if (buf[0] == '%' && buf[1] == '%'
+     && strncmp(buf+2, "BoundingBox:", 12) == 0) {
+if (sscanf(buf+14, "%f %f %f %f",
+llx_p, lly_p, urx_p, ury_p) == 4) {
+    fclose(fp);
+    return;
+}
+    }
+}
+fclose(fp);
+    }
+    sprintf(errbuf, "Couldn't get BoundingBox of %s: assuming full A4 size", f);
+    specerror(errbuf);
+    *llx_p = 0.0;
+    *lly_p = 0.0;
+    *urx_p = 595.0;
+    *ury_p = 842.0;
+    return;
+}
+
+static void
+floatroundout(f)
+float f;
+{
+    integer i;
+    i = (integer)(f<0 ? f-0.5 : f+0.5);
+    if (i-f < 0.001 && i-f > -0.001) {
+numout((integer)i);
+    } else {
+floatout(f);
+    }
+}
+
 void
 outbangspecials() {
    if (bangspecials) {
@@ -493,6 +541,59 @@
 emspecial(p);
 return;
    }
+   if (strncmp(p, "epsfile=", 8)==0) {/* epsf.sty for dvi2ps-j */
+float llx, lly, urx, ury;
+
+p += 8;
+sscanf(p, "%s", psfile);
+p += strlen(psfile);
+fgetboundingbox(psfile, &llx, &lly, &urx, &ury);
+hvpos();
+cmdout("@beginspecial");
+floatroundout(llx);
+cmdout("@llx");
+floatroundout(lly);
+cmdout("@lly");
+floatroundout(urx);
+cmdout("@urx");
+floatroundout(ury);
+cmdout("@ury");
+
+while (p = GetKeyVal(p, &j)) {
+switch (j) {
+  case 3: /* hsize */
+floatroundout(ValNum*10);
+cmdout("@rwi");
+break;
+  case 4: /* vsize */
+floatroundout(ValNum*10);
+cmdout("@rhi");
+break;
+  case 7: /* hscale */
+floatroundout((urx-llx)*ValNum*10);
+cmdout("@rwi");
+break;
+  case 8: /* vscale */
+floatroundout((ury-lly)*ValNum*10);
+cmdout("@rhi");
+break;
+  default:
+sprintf(errbuf, "Unknown keyword `%s' in \\special{epsfile=%s...} will be ignored\n", KeyStr, psfile);
+specerror(errbuf);
+break;
+}
+}
+
+cmdout("@setspecial");
+numout((integer)0);
+cmdout("lly");
+cmdout("ury");
+cmdout("sub");
+cmdout("TR");
+figcopyfile(psfile, 0);
+cmdout("\n@endspecial");
+return;
+   }
    break ;
 case 'p':
    if (strncmp(p, "ps:", 3)==0) {
@@ -539,6 +640,31 @@
    if (strncmp(p, "pn ", 3) == 0) {setPenSize(p+2); return;}
    if (strncmp(p, "pa ", 3) == 0) {addPath(p+2); return;}
 #endif
+   if (strncmp(p, "postscriptbox", 13)==0) { /* epsbox.sty for jdvi2kps */
+float w, h;
+float llx, lly, urx, ury;
+if (sscanf(p+13, "{%fpt}{%fpt}{%[^}]}", &w, &h, psfile) != 3)
+    break;
+fgetboundingbox(psfile, &llx, &lly, &urx, &ury);
+hvpos();
+cmdout("@beginspecial");
+floatroundout(llx);
+cmdout("@llx");
+floatroundout(lly);
+cmdout("@lly");
+floatroundout(urx);
+cmdout("@urx");
+floatroundout(ury);
+cmdout("@ury");
+floatroundout(w*10*72/72.27);
+cmdout("@rwi");
+floatroundout(h*10*72/72.27);
+cmdout("@rhi");
+cmdout("@setspecial");
+figcopyfile(psfile, 0);
+cmdout("\n@endspecial");
+return;
+   }
    break ;
 case 'l':
    if (strncmp(p, "landscape", 9)==0) return ;
@@ -673,7 +799,7 @@
       switch (j) {
  case -1: /* for compatability with old conventions, we allow a file name
            * to be given without the 'psfile=' keyword */
-         if (!psfile[0] && maccess(KeyStr)==0) /* yes we can read it */
+         if (!psfile[0] && maccess(KeyStr)==1) /* yes we can read it */
              (void)strcpy(psfile,KeyStr) ;
          else {
            sprintf(errbuf, "Unknown keyword (%s) in \\special will be ignored",
