summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipsk
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2010-05-05 09:37:32 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2010-05-05 09:37:32 +0000
commit149d652144fe416dbe4ecf9fc5cef71617ef01ff (patch)
treedd6af91d94b7a0fa3ee43fbf5996539d481c3285 /Build/source/texk/dvipsk
parent52fa6e36fd5539d6bd3546acdfb401bd99d899d6 (diff)
dvips pTeX extensions, based on patches sent by Akira
git-svn-id: svn://tug.org/texlive/trunk@18107 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipsk')
-rw-r--r--Build/source/texk/dvipsk/ChangeLog11
-rw-r--r--Build/source/texk/dvipsk/bbox.c378
-rw-r--r--Build/source/texk/dvipsk/color.c2
-rw-r--r--Build/source/texk/dvipsk/dopage.c164
-rw-r--r--Build/source/texk/dvipsk/dospecial.c196
-rw-r--r--Build/source/texk/dvipsk/download.c25
-rw-r--r--Build/source/texk/dvipsk/drawPS.c60
-rw-r--r--Build/source/texk/dvipsk/dvips.c43
-rw-r--r--Build/source/texk/dvipsk/dvips.h19
-rw-r--r--Build/source/texk/dvipsk/dvips.help3
-rw-r--r--Build/source/texk/dvipsk/finclude.c1
-rw-r--r--Build/source/texk/dvipsk/fontdef.c1
-rw-r--r--Build/source/texk/dvipsk/loadfont.c1
-rw-r--r--Build/source/texk/dvipsk/output.c423
-rw-r--r--Build/source/texk/dvipsk/pprescan.c37
-rw-r--r--Build/source/texk/dvipsk/prescan.c8
-rw-r--r--Build/source/texk/dvipsk/protos.h7
-rw-r--r--Build/source/texk/dvipsk/protos_add.h2
-rw-r--r--Build/source/texk/dvipsk/repack.c2
-rw-r--r--Build/source/texk/dvipsk/resident.c78
-rw-r--r--Build/source/texk/dvipsk/scanpage.c33
-rw-r--r--Build/source/texk/dvipsk/search.c1
-rw-r--r--Build/source/texk/dvipsk/skippage.c22
-rw-r--r--Build/source/texk/dvipsk/tex.lpro17
-rw-r--r--Build/source/texk/dvipsk/tfmload.c179
-rw-r--r--Build/source/texk/dvipsk/virtualfont.c44
26 files changed, 1246 insertions, 511 deletions
diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog
index badabd9570c..60f1c2193d4 100644
--- a/Build/source/texk/dvipsk/ChangeLog
+++ b/Build/source/texk/dvipsk/ChangeLog
@@ -1,3 +1,14 @@
+2010-05-05 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Implement pTeX extensions, based on patches sent by Akira.
+ Modified to reproduce former output files. Added -noptex option.
+ * bbox.c, color.c, dopage.c, dospecial.c, download.c, drawPS.c,
+ dvips.[ch], finclude.c, fontdef.c, loadfont.c, output.c,
+ pprescan.c, prescan.c, protos.h, protos_add.h, repack.c,
+ resident.c, scanpage.c, search.c, skippage.c, tex.lpro,
+ tfmload.c, virtualfont.c: pTeX extensions.
+ * dvips.1, dvips.help, dvips.texi: Documentation.
+
2010-05-03 Jan Lieskovsky <jlieskov@redhat.com>
* dospecial.c (predospecial, bbdospecial): avoid numeric overflow.
diff --git a/Build/source/texk/dvipsk/bbox.c b/Build/source/texk/dvipsk/bbox.c
index 5a321890e6a..8073df25fb6 100644
--- a/Build/source/texk/dvipsk/bbox.c
+++ b/Build/source/texk/dvipsk/bbox.c
@@ -33,9 +33,12 @@ bbtfmload(register fontdesctype *curfnt)
register integer i, j;
register integer li, cd = 0;
integer scaledsize;
+ integer id, nt = 0;
integer nw, nh, nd, ns, hd;
integer bc, ec;
integer nco = 0, ncw = 0, npc = 0, no_repeats = 0;
+ halfword *index = NULL;
+ halfword *chartype = NULL;
integer *scaled;
integer *chardat;
int font_level;
@@ -51,9 +54,15 @@ bbtfmload(register fontdesctype *curfnt)
* Next, we read the font data from the tfm file, and store it in
* our own arrays.
*/
- li = tfm16();
- if (li!=0) {
+ curfnt->dir = 0;
+ id = tfm16();
+ if (id != 0) {
font_level = -1;
+ if (id == 9 || id == 11) {
+ if (noptex) badtfm("length");
+ if (id == 9) curfnt->dir = id;
+ nt = tfm16(); li = tfm16();
+ }
hd = tfm16();
bc = tfm16(); ec = tfm16();
nw = tfm16(); nh = tfm16(); nd = tfm16();
@@ -62,7 +71,8 @@ bbtfmload(register fontdesctype *curfnt)
ns += tfm16();
ns += tfm16();
li = tfm16();
- if (hd<2 || bc>ec+1 || ec>255 || nw>256 || nh>16 || nd>16)
+ if ((hd<2 || bc>ec+1 || ec>255 || nw>256 || nh>16 || nd>16) &&
+ id != 9 && id != 11)
badtfm("header");
} else { /* In an .ofm file */
if (noomega) badtfm("length");
@@ -81,10 +91,10 @@ bbtfmload(register fontdesctype *curfnt)
|| bc>ec+1 || ec>65535 || nw>65536 || nh>256 || nd>256)
badtfm("header");
if (font_level==1) {
- nco = tfm32();
- ncw = tfm32();
- npc = tfm32();
- for (i=0; i<12; i++) li=tfm32();
+ nco = tfm32();
+ ncw = tfm32();
+ npc = tfm32();
+ for (i=0; i<12; i++) li=tfm32();
}
}
li = tfm32();
@@ -92,30 +102,54 @@ bbtfmload(register fontdesctype *curfnt)
li = tfm32();
pretend_no_chars=ec+1;
- if (pretend_no_chars<256) pretend_no_chars=256;
- bbcurfnt->bbchardesc = (bbchardesctype *)
- xmalloc(pretend_no_chars*sizeof(bbchardesctype));
- for (i=2; i<((font_level==1)?nco-29:hd); i++)
- li = tfm32();
- chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer));
- for (i=0; i<pretend_no_chars; i++)
- chardat[i] = -1;
- for (i=bc; i<=ec; i++) {
- if (no_repeats>0) {
- no_repeats--;
- } else if (font_level>=0) {
- cd = tfm32();
+ if (id == 9 || id == 11) {
+ chardat = (integer *) xmalloc(256*sizeof(integer));
+ bbcurfnt->bbchardesc = (bbchardesctype *)
+ xmalloc((MAX_2BYTES_CODE+1)*sizeof(bbchardesctype));
+ for (i=2; i<hd; i++)
li = tfm32();
- if (font_level==1) {
- no_repeats = tfm16();
- for (j=0; j<(npc|1); j++) tfm16();
- ncw -= 3 + npc/2;
- }
- } else {
- cd = tfm16();
+ index = (halfword *)xmalloc(nt * sizeof(halfword));
+ chartype = (halfword *)xmalloc(nt * sizeof(halfword));
+ li = tfm16();
+ li = tfm16();
+ for (i=1; i<nt; i++) {
li = tfm16();
+ index[i] = li;
+ chartype[i] = tfm16();
+ }
+ for (i=0; i<256; i++)
+ chardat[i] = -1;
+ } else {
+ if (pretend_no_chars<256) pretend_no_chars=256;
+ bbcurfnt->bbchardesc = (bbchardesctype *)
+ xmalloc(pretend_no_chars*sizeof(bbchardesctype));
+ for (i=2; i<((font_level==1)?nco-29:hd); i++)
+ li = tfm32();
+ chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer));
+ for (i=0; i<pretend_no_chars; i++)
+ chardat[i] = -1;
+ }
+ for (i=bc; i<=ec; i++) {
+ if (id == 9 || id == 11) {
+ chardat[i] = tfm16();
+ li = tfm16();
+ } else {
+ if (no_repeats>0) {
+ no_repeats--;
+ } else if (font_level>=0) {
+ cd = tfm32();
+ li = tfm32();
+ if (font_level==1) {
+ no_repeats = tfm16();
+ for (j=0; j<(npc|1); j++) tfm16();
+ ncw -= 3 + npc/2;
+ }
+ } else {
+ cd = tfm16();
+ li = tfm16();
+ }
+ if (cd) chardat[i] = cd;
}
- if (cd) chardat[i] = cd;
}
if (font_level==1&&ncw!=0) {
char *msg = concat ("Table size mismatch in ", curfnt->name);
@@ -123,68 +157,125 @@ bbtfmload(register fontdesctype *curfnt)
free(msg);
}
scaledsize = curfnt->scaledsize;
- scaled = (integer *) xmalloc((nh + nd)*sizeof(integer));
- for (i=0; i<nw; i++)
- tfm32();
- for (i=0; i<nh + nd; i++)
- scaled[i] = scalewidth(tfm32(), scaledsize);
+ if (id == 9 || id == 11) {
+ scaled = (integer *) xmalloc(300*sizeof(integer));
+ for (i=0; i<nw + nh + nd; i++)
+ scaled[i] = scalewidth(tfm32(), scaledsize);
+ } else {
+ scaled = (integer *) xmalloc((nh + nd)*sizeof(integer));
+ for (i=0; i<nw; i++)
+ tfm32();
+ for (i=0; i<nh + nd; i++)
+ scaled[i] = scalewidth(tfm32(), scaledsize);
+ }
for (i=0; i<ns; i++)
tfm32();
slant = tfm32();
(void)fclose(tfmfile);
- for (i=0; i<pretend_no_chars; i++) {
- cc = &(bbcurfnt->bbchardesc[i]);
- if (chardat[i] != -1) {
- halfword iw;
- int ih, id;
- if (font_level>=0) {
- iw = chardat[i] >> 16;
- ih = (chardat[i] >> 8) & 255;
- id = chardat[i] & 255;
+
+ if (id == 9 || id == 11) {
+ for (i=0; i<MAX_2BYTES_CODE+1; i++) {
+ cc = &(bbcurfnt->bbchardesc[i]);
+ if (chardat[0] != -1) {
+ cc->ury = scaled[((chardat[0] >> 4) & 15) + nw];
+ cc->lly = - scaled[(chardat[0] & 15) + nw + nh];
+ cc->llx = 0;
+ cc->urx = curfnt->chardesc[0].TFMwidth;
} else {
- iw = chardat[i] >> 8;
- ih = (chardat[i] >> 4) & 15;
- id = chardat[i] & 15;
+ cc->llx = cc->lly = cc->urx = cc->ury = 0;
}
- if (iw>=nw || ih>=nh || id>=nd) badtfm("char info");
- cc->ury = scaled[ih];
- cc->lly = - scaled[nh + id];
- cc->llx = 0;
- cc->urx = curfnt->chardesc[i].TFMwidth;
- } else {
- cc->llx = cc->lly = cc->urx = cc->ury = 0;
}
- }
- if (slant) {
+ for (i=1; i<nt; i++) {
+ cc = &(bbcurfnt->bbchardesc[index[i]]);
+ if (chardat[chartype[i]] != -1) {
+ cc->ury = scaled[((chardat[chartype[i]] >> 4) & 15) + nw];
+ cc->lly = - scaled[(chardat[chartype[i]] & 15) + nw + nh];
+ cc->llx = 0;
+ cc->urx = curfnt->chardesc[index[i]].TFMwidth;
+ } else {
+ cc->llx = cc->lly = cc->urx = cc->ury = 0;
+ }
+ }
+ free(index);
+ free(chartype);
+ } else {
for (i=0; i<pretend_no_chars; i++) {
cc = &(bbcurfnt->bbchardesc[i]);
- li = scalewidth(cc->lly, slant);
- if (slant > 0) cc->llx += li;
- else cc->urx += li;
- li = scalewidth(cc->ury, slant);
- if (slant > 0) cc->urx += li;
- else cc->llx += li;
+ if (chardat[i] != -1) {
+ halfword iw;
+ int ih, id;
+ if (font_level>=0) {
+ iw = chardat[i] >> 16;
+ ih = (chardat[i] >> 8) & 255;
+ id = chardat[i] & 255;
+ } else {
+ iw = chardat[i] >> 8;
+ ih = (chardat[i] >> 4) & 15;
+ id = chardat[i] & 15;
+ }
+ if (iw>=nw || ih>=nh || id>=nd) badtfm("char info");
+ cc->ury = scaled[ih];
+ cc->lly = - scaled[nh + id];
+ cc->llx = 0;
+ cc->urx = curfnt->chardesc[i].TFMwidth;
+ } else {
+ cc->llx = cc->lly = cc->urx = cc->ury = 0;
+ }
+ }
+ }
+ if (slant) {
+ if (id == 9 || id == 11) {
+ for (i=0; i<MAX_2BYTES_CODE+1; i++) {
+ cc = &(bbcurfnt->bbchardesc[i]);
+ li = scalewidth(cc->lly, slant);
+ if (slant > 0) cc->llx += li;
+ else cc->urx += li;
+ li = scalewidth(cc->ury, slant);
+ if (slant > 0) cc->urx += li;
+ else cc->llx += li;
+ }
+ } else {
+ for (i=0; i<pretend_no_chars; i++) {
+ cc = &(bbcurfnt->bbchardesc[i]);
+ li = scalewidth(cc->lly, slant);
+ if (slant > 0) cc->llx += li;
+ else cc->urx += li;
+ li = scalewidth(cc->ury, slant);
+ if (slant > 0) cc->urx += li;
+ else cc->llx += li;
+ }
}
}
free(chardat);
free(scaled);
}
static integer llx, lly, urx, ury;
-void
-bbspecial(integer h, integer v, int nbytes)
+static void
+bbspecial(integer h, integer v, integer dir, int nbytes)
{
float *r = bbdospecial(nbytes);
if (r) {
/* convert from magnified PostScript units back to scaled points */
real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0;
- if (llx > h + r[0] / conv)
- llx = (integer) (h + r[0] / conv);
- if (lly > v - r[3] / conv)
- lly = (integer) (v - r[3] / conv);
- if (urx < h + r[2] / conv)
- urx = (integer) (h + r[2] / conv);
- if (ury < v - r[1] / conv)
- ury = (integer) (v - r[1] / conv);
+ if (!dir) {
+ if (llx > h + r[0] / conv)
+ llx = (integer) (h + r[0] / conv);
+ if (lly > v - r[3] / conv)
+ lly = (integer) (v - r[3] / conv);
+ if (urx < h + r[2] / conv)
+ urx = (integer) (h + r[2] / conv);
+ if (ury < v - r[1] / conv)
+ ury = (integer) (v - r[1] / conv);
+ } else {
+ if (llx > h + r[1] / conv)
+ llx = (integer)(h + r[1] / conv);
+ if (lly > v + r[2] / conv)
+ lly = (integer)(v + r[2] / conv);
+ if (urx < h + r[3] / conv)
+ urx = (integer)(h + r[3] / conv);
+ if (ury < v + r[0] / conv)
+ ury = (integer)(v + r[0] / conv);
+ }
}
}
void
@@ -197,14 +288,14 @@ bbdopage(void)
register fontmaptype *cfnt;
bbfontmaptype *bbcfnt;
integer fnt;
- integer mychar;
+ integer mychar;
int charmove;
struct dvistack *sp = stack;
- integer v, w, x, y, z;
+ integer v, w, x, y, z, dir;
register fontdesctype *curfnt = 0;
register bbfontdesctype *bbcurfnt = 0;
- w = x = y = z = 0;
+ w = x = y = z = dir = 0;
h = 0; v = 0;
llx = lly = 1000000000;
urx = ury = -1000000000;
@@ -212,6 +303,20 @@ bbdopage(void)
while (1) {
switch (cmd=dvibyte()) {
case 138: break;
+case 135: /* put3 */
+ if (noptex) error("! synch");
+ mychar = dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ charmove = 0;
+ goto dochar;
+case 130: /* set3 */
+ if (noptex) error("! synch");
+ mychar = dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ charmove = 1;
+ goto dochar;
case 134: /* put2 */
if (noomega) error("! synch");
mychar = dvibyte();
@@ -234,35 +339,62 @@ default: /* these are commands 0 (setchar0) thru 127 (setchar127) */
charmove = 1;
dochar:
cd = &(curfnt->chardesc[mychar]);
- bcd = &(bbcurfnt->bbchardesc[mychar]);
- if (h + bcd->llx < llx) llx = h + bcd->llx;
- if (h + bcd->urx > urx) urx = h + bcd->urx;
- if (v - bcd->ury < lly) lly = v - bcd->ury;
- if (v - bcd->lly > ury) ury = v - bcd->lly;
- if (charmove)
- h += cd->TFMwidth;
+ bcd = &(bbcurfnt->bbchardesc[CD_IDX(mychar)]);
+ if (!dir) {
+ if (h + bcd->llx < llx) llx = h + bcd->llx;
+ if (h + bcd->urx > urx) urx = h + bcd->urx;
+ if (v - bcd->ury < lly) lly = v - bcd->ury;
+ if (v - bcd->lly > ury) ury = v - bcd->lly;
+ } else {
+ if (h + bcd->ury < llx) llx = h + bcd->ury;
+ if (h + bcd->lly > urx) urx = h + bcd->lly;
+ if (v + bcd->llx < lly) lly = v + bcd->llx;
+ if (v + bcd->urx > ury) ury = v + bcd->urx;
+ }
+ if (charmove) {
+ if (!dir)
+ h += cd->TFMwidth;
+ else
+ v += cd->TFMwidth;
+ }
break;
-case 130: case 131: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255: /* unimplemented or illegal commands */
+case 255: /* pTeX's dir or undefined */
+ if (!noptex) {
+ dir = dvibyte();
+ break;
+ }
+case 131: case 136: case 139: /* set4, put4, bop */
+case 247: case 248: case 249: /* pre, post, post_post */
+case 250: case 251: case 252: case 253: case 254: /* undefined */
error("! synch");
case 132: case 137: /* rules */
{ integer ry, rx;
ry = signedquad(); rx = signedquad();
if (rx>0 && ry>0) {
- if (h < llx) llx = h;
- if (v - ry < lly) lly = v - ry;
- if (h + rx > urx) urx = h + rx;
- if (v > ury) ury = v;
+ if (!dir) {
+ if (h < llx) llx = h;
+ if (v - ry < lly) lly = v - ry;
+ if (h + rx > urx) urx = h + rx;
+ if (v > ury) ury = v;
+ } else {
+ if (h < llx) llx = h;
+ if (v + rx < lly) lly = v + rx;
+ if (h + ry > urx) urx = h + ry;
+ if (v > ury) ury = v;
+ }
} else
rx = 0;
- if (cmd != 137)
- h += rx;
+ if (cmd != 137) {
+ if (!dir)
+ h += rx;
+ else
+ v += rx;
+ }
break;
}
case 141: /* push */
sp->h = h; sp->v = v;
- sp->w = w; sp->x = x; sp->y = y; sp->z = z;
+ sp->w = w; sp->x = x; sp->y = y; sp->z = z; sp->dir = dir;
if (++sp >= &stack[STACKSIZE]) error("! Out of stack space");
break;
case 140: /* eop or end of virtual character */
@@ -270,36 +402,36 @@ case 140: /* eop or end of virtual character */
case 142: /* pop */
if (--sp < stack) error("! More pops than pushes");
h = sp->h; v = sp->v;
- w = sp->w; x = sp->x; y = sp->y; z = sp->z;
+ w = sp->w; x = sp->x; y = sp->y; z = sp->z; dir = sp->dir;
break;
-case 143: h += signedbyte(); break;
-case 144: h += signedpair(); break;
-case 145: h += signedtrio(); break;
-case 146: h += signedquad(); break;
-case 147: h += w; break;
-case 148: h += (w = signedbyte()); break;
-case 149: h += (w = signedpair()); break;
-case 150: h += (w = signedtrio()); break;
-case 151: h += (w = signedquad()); break;
-case 152: h += x; break;
-case 153: h += (x = signedbyte()); break;
-case 154: h += (x = signedpair()); break;
-case 155: h += (x = signedtrio()); break;
-case 156: h += (x = signedquad()); break;
-case 157: v += signedbyte(); break;
-case 158: v += signedpair(); break;
-case 159: v += signedtrio(); break;
-case 160: v += signedquad(); break;
-case 161: v += y; break;
-case 162: v += (y = signedbyte()); break;
-case 163: v += (y = signedpair()); break;
-case 164: v += (y = signedtrio()); break;
-case 165: v += (y = signedquad()); break;
-case 166: v += z; break;
-case 167: v += (z = signedbyte()); break;
-case 168: v += (z = signedpair()); break;
-case 169: v += (z = signedtrio()); break;
-case 170: v += (z = signedquad()); break;
+case 143: if (!dir) h += signedbyte(); else v += signedbyte(); break;
+case 144: if (!dir) h += signedpair(); else v += signedpair(); break;
+case 145: if (!dir) h += signedtrio(); else v += signedtrio(); break;
+case 146: if (!dir) h += signedquad(); else v += signedquad(); break;
+case 147: if (!dir) h += w; else v += w; break;
+case 148: if (!dir) h += (w = signedbyte()); else v += (w = signedbyte()); break;
+case 149: if (!dir) h += (w = signedpair()); else v += (w = signedpair()); break;
+case 150: if (!dir) h += (w = signedtrio()); else v += (w = signedtrio()); break;
+case 151: if (!dir) h += (w = signedquad()); else v += (w = signedquad()); break;
+case 152: if (!dir) h += x; else v += x; break;
+case 153: if (!dir) h += (x = signedbyte()); else v += (x = signedbyte()); break;
+case 154: if (!dir) h += (x = signedpair()); else v += (x = signedpair()); break;
+case 155: if (!dir) h += (x = signedtrio()); else v += (x = signedtrio()); break;
+case 156: if (!dir) h += (x = signedquad()); else v += (x = signedquad()); break;
+case 157: if (!dir) v += signedbyte(); else h -= signedbyte(); break;
+case 158: if (!dir) v += signedpair(); else h -= signedpair(); break;
+case 159: if (!dir) v += signedtrio(); else h -= signedtrio(); break;
+case 160: if (!dir) v += signedquad(); else h -= signedquad(); break;
+case 161: if (!dir) v += y; else h -= y; break;
+case 162: if (!dir) v += (y = signedbyte()); else h -= (y = signedbyte()); break;
+case 163: if (!dir) v += (y = signedpair()); else h -= (y = signedpair()); break;
+case 164: if (!dir) v += (y = signedtrio()); else h -= (y = signedtrio()); break;
+case 165: if (!dir) v += (y = signedquad()); else h -= (y = signedquad()); break;
+case 166: if (!dir) v += z; else h += z; break;
+case 167: if (!dir) v += (z = signedbyte()); else h -= (z = signedbyte()); break;
+case 168: if (!dir) v += (z = signedpair()); else h -= (z = signedpair()); break;
+case 169: if (!dir) v += (z = signedtrio()); else h -= (z = signedtrio()); break;
+case 170: if (!dir) v += (z = signedquad()); else h -= (z = signedquad()); break;
case 171: case 172: case 173: case 174: case 175: case 176: case 177:
case 178: case 179: case 180: case 181: case 182: case 183: case 184:
case 185: case 186: case 187: case 188: case 189: case 190: case 191:
@@ -332,10 +464,10 @@ case 243: case 244: case 245: case 246: /*fntdef1 */
skipover(cmd - 230);
skipover(dvibyte() + dvibyte());
break;
-case 239: bbspecial(h, v, (int)dvibyte()); break;
-case 240: bbspecial(h, v, (int)twobytes()); break;
-case 241: bbspecial(h, v, (int)threebytes()); break;
-case 242: bbspecial(h, v, (int)signedquad()); break;
+case 239: bbspecial(h, v, dir, (int)dvibyte()); break;
+case 240: bbspecial(h, v, dir, (int)twobytes()); break;
+case 241: bbspecial(h, v, dir, (int)threebytes()); break;
+case 242: bbspecial(h, v, dir, (int)signedquad()); break;
}
}
}
diff --git a/Build/source/texk/dvipsk/color.c b/Build/source/texk/dvipsk/color.c
index a4ee12b8b19..34a264f901c 100644
--- a/Build/source/texk/dvipsk/color.c
+++ b/Build/source/texk/dvipsk/color.c
@@ -26,7 +26,7 @@
*/
#define COLORHASH (89)
#define MAXCOLORLEN (120) /* maximum color length for background */
-#define INITCOLORLEN (3000) /* initial stack size in chars */
+#define INITCOLORLEN (10000) /* initial stack size in chars */
/*
* This is where we store the color information for a particular page.
* If we free all of these, we free all of the allocated color
diff --git a/Build/source/texk/dvipsk/dopage.c b/Build/source/texk/dvipsk/dopage.c
index 436508db76b..019300f8c85 100644
--- a/Build/source/texk/dvipsk/dopage.c
+++ b/Build/source/texk/dvipsk/dopage.c
@@ -9,24 +9,20 @@
*/
#include "protos_add.h"
-#ifdef XENIX
+#if defined(XENIX) || defined(__THINK__)
#define PixRound(x) ((integer)(x + (iconv >> 1)) / iconv)
#define VPixRound(x) ((integer)(x + (viconv >> 1)) / viconv)
#else
-#ifdef __THINK__
-#define PixRound(x) ((integer)(x + (iconv >> 1)) / iconv)
-#define VPixRound(x) ((integer)(x + (viconv >> 1)) / viconv)
-#else
#define PixRound(x) ((integer)(floor(((x) * conv) + 0.5)))
#define VPixRound(x) ((integer)(floor(((x) * vconv) + 0.5)))
#endif
-#endif
/*
* Now we have the dopage procedure.
* Most error checking is suppressed because the prescan has already
* verified that the DVI data is OK....except for stack over/underflow.
*/
struct dvistack stack[STACKSIZE];
+integer dir;
#ifdef HPS
integer hhmem, vvmem;
integer pushcount = 0;
@@ -35,6 +31,7 @@ Boolean NEED_NEW_BOX = 0;
integer H_BREAK; /* An empirical parameter for guessing line breaks; needs
dpi dependence */
#endif
+
void
dopage(void)
{
@@ -52,20 +49,12 @@ dopage(void)
integer roundpos;
integer thinspace;
integer vertsmallspace;
-#ifdef XENIX
+#if defined(XENIX) || defined(__THINK__)
integer iconv;
integer viconv;
iconv = (integer)(1.0 / conv + 0.5);
viconv = (integer)(1.0 / vconv + 0.5);
-#else
-#ifdef __THINK__
- integer iconv;
- integer viconv;
-
- iconv = (integer)(1.0 / conv + 0.5);
- viconv = (integer)(1.0 / vconv + 0.5);
-#endif
#endif
#ifdef EMTEX
emclear();
@@ -79,7 +68,7 @@ dopage(void)
if (HPS_FLAG) pagecounter++;
H_BREAK = (30 * DPI / 400 ); /* 30 seems to have worked well at 400 dpi */
#endif
- w = x = y = z = 0;
+ w = x = y = z = dir = rdir = fdir = 0;
h = (integer) (DPI / conv * hoff / 4736286.72);
v = (integer) (DPI / conv * voff / 4736286.72);
hh = PixRound(h);
@@ -94,6 +83,20 @@ case 138: goto beginloop; /* nop command does nuttin */
* For put1 commands, we subtract the width of the character before
* dropping through to the normal character setting routines. This
*/
+case 135: /* put3 */
+ if (noptex) error("! synch");
+ mychar = dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ charmove = 0;
+ goto dochar;
+case 130: /* set3 */
+ if (noptex) error("! synch");
+ mychar = dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ charmove = 1;
+ goto dochar;
case 134: /* put2 */
if (noomega) error("! synch");
mychar = dvibyte();
@@ -130,13 +133,26 @@ dochar:
if (cd->flags & EXISTS) {
if (curfnt->loaded == 2) { /* virtual character being typeset */
if (charmove) {
- sp->hh = hh + cd->pixelwidth;
- sp->h = h + cd->TFMwidth;
+ if (!dir) {
+ sp->hh = hh + cd->pixelwidth;
+ sp->h = h + cd->TFMwidth;
+ } else {
+ sp->v = v + cd->TFMwidth;
+ sp->vv = PixRound(sp->v);
+ }
+ } else {
+ if (!dir) {
+ sp->hh = hh; sp->h = h;
+ } else {
+ sp->vv = vv; sp->v = v;
+ }
+ }
+ if (!dir) {
+ sp->vv = vv; sp->v = v;
} else {
sp->hh = hh; sp->h = h;
}
- sp->vv = vv; sp-> v = v;
- sp->w = w; sp->x = x; sp->y = y; sp->z = z;
+ sp->w = w; sp->x = x; sp->y = y; sp->z = z; sp->dir = dir;
if (++sp >= &stack[STACKSIZE]) error("! Out of stack space");
w = x = y = z = 0; /* will be in relative units at new stack level */
frp->curp = curpos;
@@ -160,13 +176,25 @@ dochar:
drawchar(cd, mychar);
}
if (charmove) {
- h += cd->TFMwidth;
- hh += cd->pixelwidth;
+ if (!dir) {
+ h += cd->TFMwidth;
+ hh += cd->pixelwidth;
+ } else {
+ v += cd->TFMwidth;
+ vv += cd->pixelwidth;
+ }
}
goto setmotion;
-case 130: case 131: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255: /* unimplemented or illegal commands */
+case 255: /* pTeX's dir or undefined */
+ if (!noptex) {
+ dir = dvibyte();
+ cmddir();
+ goto beginloop;
+ }
+/* illegal commands */
+case 131: case 136: case 139: /* set4, put4, bop */
+case 247: case 248: case 249: /* pre, post, post_post */
+case 250: case 251: case 252: case 253: case 254: /* undefined */
error("! synch");
case 132: case 137: /* rules */
{ integer ry, rx , rxx, ryy;
@@ -176,13 +204,30 @@ case 132: case 137: /* rules */
rx = scalewidth(rx, (frp-1)->curf->scaledsize);
ry = scalewidth(ry, (frp-1)->curf->scaledsize);
}
- rxx = (int)(conv * rx + 0.9999999);
- ryy = (int)(vconv * ry + 0.9999999);
+ if (!dir) {
+ rxx = (int)(conv * rx + 0.9999999);
+ ryy = (int)(vconv * ry + 0.9999999);
+ }
+ else {
+ rxx = (int)(vconv * rx + 0.9999999);
+ ryy = (int)(conv * ry + 0.9999999);
+ }
+ /* Heiko Oberdiek 2001/06/03: synchronisation added for vertical rules
+ because of alignment reasons.
+ */
+ if (ry > rx) {
+ hh = PixRound(h);
+ }
drawrule(rxx, ryy);
} else
rxx = 0;
if (cmd == 137) goto beginloop;
- h += rx; hh += rxx;
+ if (!dir) {
+ h += rx; hh += rxx;
+ }
+ else {
+ v += rx; vv += rxx;
+ }
goto setmotion;
}
case 141: /* push */
@@ -200,7 +245,7 @@ case 141: /* push */
/* printf("push %i, %i\n", pushcount, inHTMLregion); */
#endif
sp->hh = hh; sp->vv = vv; sp->h = h; sp->v = v;
- sp->w = w; sp->x = x; sp->y = y; sp->z = z;
+ sp->w = w; sp->x = x; sp->y = y; sp->z = z; sp->dir = dir;
if (++sp >= &stack[STACKSIZE]) error("! Out of stack space");
goto beginloop;
case 140: /* eop or end of virtual character */
@@ -231,13 +276,14 @@ case 142: /* pop */
hhmem = hh; vvmem = vv;
}
#endif
- hh = sp->hh; vv = sp->vv; h = sp->h; v = sp->v;
- w = sp->w; x = sp->x; y = sp->y; z = sp->z;
+ hh = sp->hh; vv = sp->vv; h = sp->h; v = sp->v;
+ w = sp->w; x = sp->x; y = sp->y; z = sp->z; dir = sp->dir;
#ifdef HPS
if (HPS_FLAG && inHTMLregion && (hhmem - hh > H_BREAK) && (pushcount > 0) &&
(pushcount < current_pushcount))
end_current_box();
#endif
+ cmddir();
goto beginloop;
case 143: /* right1 */
p = signedbyte(); goto horizontalmotion;
@@ -348,14 +394,26 @@ verticalmotion:
/* vertical motion cases */
if (curpos)
p = scalewidth(p, (frp-1)->curf->scaledsize);
- v += p;
- if (p >= vertsmallspace) vv = VPixRound(v);
- else if (p <= -vertsmallspace) vv = VPixRound(v);
- else
- { vv += VPixRound(p);
- roundpos = VPixRound(v);
- if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift;
- else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift;
+ if (!dir) {
+ v += p;
+ if (p >= vertsmallspace) vv = VPixRound(v);
+ else if (p <= -vertsmallspace) vv = VPixRound(v);
+ else
+ { vv += VPixRound(p);
+ roundpos = VPixRound(v);
+ if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift;
+ else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift;
+ }
+ } else {
+ h -= p;
+ if (p >= vertsmallspace) hh = VPixRound(h);
+ else if (p <= -vertsmallspace) hh = VPixRound(h);
+ else
+ { hh -= VPixRound(p);
+ roundpos = VPixRound(h);
+ if (roundpos - hh > vmaxdrift) hh = roundpos - vmaxdrift;
+ else if (hh - roundpos > vmaxdrift) hh = roundpos + vmaxdrift;
+ }
}
#ifdef HPS
/* printf("Doing vertical motion: p = %i, v = %i, vv = %i\n",p,v,vv); */
@@ -373,18 +431,32 @@ horizontalmotion:
/* horizontal motion cases */
if (curpos)
p = scalewidth(p, (frp-1)->curf->scaledsize);
- h += p;
- if (p >= thinspace || p <= -6 * thinspace) {
- hh = PixRound(h); goto beginloop;
+ if (!dir) {
+ h += p;
+ if (p >= thinspace || p <= -6 * thinspace) {
+ hh = PixRound(h); goto beginloop;
+ }
+ else hh += PixRound(p);
+ } else {
+ v += p;
+ if (p >= thinspace || p <= -6 * thinspace) {
+ vv = PixRound(v); goto beginloop;
+ }
+ else vv += PixRound(p);
}
- else hh += PixRound(p);
#ifdef HPS
/* printf("Doing horizontal motion: p = %i, h = %i, hh = %i\n",p,h,hh); */
#endif
setmotion:
- roundpos = PixRound(h);
- if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift; }
- else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift; }
+ if (!dir) {
+ roundpos = PixRound(h);
+ if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift; }
+ else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift; }
+ } else {
+ roundpos = PixRound(v);
+ if (roundpos - vv > maxdrift) { vv = roundpos - maxdrift; }
+ else if (vv - roundpos > maxdrift) { vv = roundpos + maxdrift; }
+ }
goto beginloop;
} /* end of the big switch */
diff --git a/Build/source/texk/dvipsk/dospecial.c b/Build/source/texk/dvipsk/dospecial.c
index 2cdf3c2f4fb..6dde4f95fc6 100644
--- a/Build/source/texk/dvipsk/dospecial.c
+++ b/Build/source/texk/dvipsk/dospecial.c
@@ -30,14 +30,14 @@ struct bangspecial {
void
specerror(const char *s)
{
- if (specialerrors > 0
+ if (specialerrors > 0
#ifdef KPATHSEA
&& !kpse_tex_hush ("special")
#endif
) {
error(s);
specialerrors--;
- } else if (specialerrors == 0
+ } else if (specialerrors == 0
#ifdef KPATHSEA
&& !kpse_tex_hush ("special")
#endif
@@ -105,6 +105,81 @@ dobs(register struct bangspecial *q)
}
}
+/* added for dvi2ps & jdvi2kps format */
+static char *mfgets(char *buf, unsigned int bytes, FILE *fp);
+
+static void
+fgetboundingbox(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 (mfgets(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;
+}
+
+static char *
+mfgets(char *buf, unsigned int bytes, FILE *fp)
+{
+ int i, cc;
+
+ for (i = 0; i < bytes; i++) {
+ cc = fgetc(fp);
+ if (cc == 0x0a || cc == 0x0d) {
+ if (cc == 0x0d) {
+ cc = fgetc(fp);
+ if (cc != 0x0a) {
+ ungetc(cc, fp);
+ }
+ }
+ cc = 0x0a;
+ buf[i] = cc;
+ buf[i+1] = '\0';
+ return buf;
+ } else if (cc == EOF) {
+ buf[i] = '\0';
+ if (i == 0) return NULL;
+ else return buf;
+ } else {
+ buf[i] = cc;
+ }
+ }
+ buf[i] = '\0';
+ return buf;
+}
+
+static void
+floatroundout(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);
+ }
+}
+/* end of addition */
+
void
outbangspecials(void) {
if (bangspecials) {
@@ -193,7 +268,7 @@ int
IsSame(const char *a, const char *b)
{
for(; *a != '\0'; ) {
- if( TOLOWER(*a) != TOLOWER(*b) )
+ if( TOLOWER(*a) != TOLOWER(*b) )
return( 0 );
a++;
b++;
@@ -206,7 +281,7 @@ const char *ValStr; /* ... String values found */
long ValInt; /* Integer value found */
float ValNum; /* Number or Dimension value found */
-char *
+char *
GetKeyVal(char *str, int *tno) /* returns NULL if none found, else next scan point */
/* str : starting point for scan */
/* tno : table entry number of keyword, or -1 if keyword not found */
@@ -262,7 +337,7 @@ found: *tno = i;
break;
case Number:
case Dimension:
- if(sscanf(ValStr,"%f",&ValNum)!=1) {
+ if(sscanf(ValStr,"%f",&ValNum)!=1) {
sprintf(errbuf,"Non-numeric value (%s) given for keyword %s",
ValStr, KeyStr);
specerror(errbuf);
@@ -491,12 +566,6 @@ case '!':
}
break;
default:
-#if 0
- {
- /* Unknown special, must return */
- return;
- }
-#endif
break;
}
usesspecial = 1; /* now the special prolog will be sent */
@@ -516,7 +585,7 @@ maccess(char *s)
const char *tasks[] = { 0, "iff2ps", "tek2ps" };
-static char psfile[511];
+static char psfile[511];
void
dospecial(integer numbytes)
{
@@ -526,7 +595,7 @@ dospecial(integer numbytes)
register const char *q;
Boolean psfilewanted = 1;
const char *task = 0;
- char cmdbuf[111];
+ char cmdbuf[111];
#ifdef HPS
if (HPS_FLAG && PAGEUS_INTERUPPTUS) {
HREF_COUNT--;
@@ -573,6 +642,61 @@ case 'e':
emspecial(p);
return;
}
+
+/* added for dvi2ps special */
+ 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;
+ }
+/* end addition */
break;
case 'p':
if (strncmp(p, "pos:", 4)==0) return; /* positional specials */
@@ -604,7 +728,7 @@ case 'p':
for (sfp = p; *sfp && *sfp != ' '; sfp++);
}
*sfp = '\0';
- if (*p == '`')
+ if (*p == '`')
figcopyfile(p+1, 1);
else
figcopyfile (p, 0);
@@ -623,6 +747,34 @@ case 'p':
if (strncmp(p, "pn ", 3) == 0) {setPenSize(p+2); return;}
if (strncmp(p, "pa ", 3) == 0) {addPath(p+2); return;}
#endif
+
+/* added for jdvi2kps special */
+ 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;
+ }
+/* end addition */
break;
case 'l':
if (strncmp(p, "landscape", 9)==0) return;
@@ -653,9 +805,9 @@ case 'h':
for(ii=0;ii<lower_len;ii++) str[ii]=tolower(str[ii]);
do_html(str);
free(str);
- } else
+ } else
#ifdef KPATHSEA
- if (!kpse_tex_hush ("special"))
+ if (!kpse_tex_hush ("special"))
#endif
{
@@ -752,14 +904,6 @@ case '"':
return;
break;
default:
-#if 0
- {
- /* Unknown special, must return */
- sprintf(errbuf,"Unrecognized special (first 10 chars: %.10s)", p);
- specerror(errbuf);
- return;
- }
-#endif
break;
}
/* At last we get to the key/value conventions */
@@ -788,7 +932,7 @@ default:
break;
case 0: case 1: case 2: /* psfile */
if (psfile[0]) {
- sprintf(errbuf, "More than one \\special %s given; %s ignored",
+ sprintf(errbuf, "More than one \\special %s given; %s ignored",
"psfile", ValStr);
specerror(errbuf);
}
@@ -824,7 +968,7 @@ default:
} else {
fprintf (stderr, "dvips: iff2ps and tek2ps are not supported.\n");
}
- } else if (psfilewanted
+ } else if (psfilewanted
#ifdef KPATHSEA
&& !kpse_tex_hush ("special")
#endif
diff --git a/Build/source/texk/dvipsk/download.c b/Build/source/texk/dvipsk/download.c
index d0e41ebc74e..8b408ee9ad4 100644
--- a/Build/source/texk/dvipsk/download.c
+++ b/Build/source/texk/dvipsk/download.c
@@ -180,11 +180,11 @@ makepsname(register char *s, register int n)
void
lfontout(int n)
{
- char buf[10];
- char *b = buf;
- *b++ = '/';
- makepsname(b, n);
- cmdout(buf);
+ char buf[10];
+ char *b = buf;
+ *b++ = '/';
+ makepsname(b, n);
+ cmdout(buf);
}
/*
@@ -210,7 +210,7 @@ download(charusetype *p, int psfont)
for (b=0; b<16; b++)
if(p->bitmap[b] !=0)
non_empty =1;
- if(non_empty==0 && curfnt->codewidth==1)
+ if(non_empty==0 && curfnt->iswide == 0 && curfnt->codewidth==1)
return;
cmdout(name);
/* following code re-arranged - Rob Hutchings 1992Apr02 */
@@ -315,7 +315,7 @@ download(charusetype *p, int psfont)
for (b=0; b<16; b++) {
for (bit=32768; bit; bit>>=1) {
if (p->bitmap[b] & bit) {
- downchar(c, cc);
+ downchar(c, (shalfword)cc);
c->flags |= EXISTS;
} else
c->flags &= ~EXISTS;
@@ -327,6 +327,7 @@ download(charusetype *p, int psfont)
newline();
fprintf(bitfile, "%%EndDVIPSBitmapFont\n");
}
+
/*
* Magic code to deal with PostScript font partial downloading.
* We track the encodings we've seen so far and keep them in these
@@ -453,9 +454,9 @@ downpsfont(charusetype *p, charusetype *all)
error("! internal error in downpsfont");
if (!partialdownload) {
infont = all->fd->resfont->PSname;
- copyfile(all->fd->resfont->Fontfile);
+ copyfile(all->fd->resfont->Fontfile);
infont = 0;
- return;
+ return;
}
for (cc=0; cc<256; cc++)
grid[cc] = 0;
@@ -475,7 +476,7 @@ downpsfont(charusetype *p, charusetype *all)
for (b=15; b>=0; b--) {
for (bit=1; bit; bit<<=1) {
if (all->bitmap[b] & bit) {
- addGlyph(glyphs[cc]);
+ addGlyph(glyphs[cc]);
}
c--;
cc--;
@@ -521,8 +522,8 @@ downpsfont(charusetype *p, charusetype *all)
prettycolumn = 0;
}
(void)fprintf(stderr, "<%s>", realnameoffile);
- prettycolumn += strlen(realnameoffile) + 2;
- }
+ prettycolumn += strlen(realnameoffile) + 2;
+ }
if (! disablecomments)
(void)fprintf(bitfile, "%%%%EndFont \n");
}
diff --git a/Build/source/texk/dvipsk/drawPS.c b/Build/source/texk/dvipsk/drawPS.c
index b23a75e27ee..c010697020b 100644
--- a/Build/source/texk/dvipsk/drawPS.c
+++ b/Build/source/texk/dvipsk/drawPS.c
@@ -100,19 +100,21 @@ char RCSid[] =
/* convert from tpic units to PS units */
#define PixRound(a,b) zPixRound((a),(b))
-#define convPS(x) PixRound((x),convRESOLUTION)
-#define convVPS(x) PixRound((x),convVRESOLUTION)
+#define convPS(x) PixRound((x), dir ? convVRESOLUTION : convRESOLUTION)
+#define convVPS(x) PixRound((x), dir ? convRESOLUTION : convVRESOLUTION)
+#define ConvPS(x) PixRound((x), convRESOLUTION)
+#define ConvVPS(x) PixRound((x), convVRESOLUTION)
/* convert from tpic locn to abs horiz PS locn */
-#define hconvPS(x) (hh + convPS(x))
+#define hconvPS(x) dir ? (vv + ConvVPS(x)) : (hh + ConvPS(x))
/* convert from tpic locn to abs vert PS locn */
-#define vconvPS(x) (vv + convVPS(x))
+#define vconvPS(x) dir ? (-hh + ConvPS(x)) : (vv + ConvVPS(x))
/* convert to degrees */
#define convDeg(x) (360*(x)/(2*3.14159265358979))
/* if PostScript had splines, i wouldnt need to store the path */
-#define MAXPATHS 600 /* maximum number of path segments */
-#define NONE 0 /* for shading */
+#define MAXPATHS 6000 /* maximum number of path segments */
+#define NONE 0 /* for shading */
#define BLACK 1 /* for shading */
#define GRAY 2 /* MJ; for shading */
#define WHITE 3 /* for shading */
@@ -200,15 +202,15 @@ arc(char *cp, int invis)
doubleout(hconvPS(xc));
doubleout(vconvPS(yc));
doubleout(convPS(xrad));
- if (xrad != yrad && VDPI == DPI)
- doubleout(convPS(yrad));
+ if (xrad != yrad || VDPI != DPI)
+ doubleout(convVPS(yrad));
doubleout(convDeg(startAngle));
doubleout(convDeg(endAngle));
if (xrad == yrad && VDPI == DPI) /* for arcs and circles */
- cmdout("arc");
+ cmdout("arc");
else
- cmdout("ellipse");
+ cmdout("ellipse");
cmdout(FILL);
shading = NONE;
@@ -232,12 +234,12 @@ arc(char *cp, int invis)
doubleout(hconvPS(xc));
doubleout(vconvPS(yc));
doubleout(convPS(xrad));
- if (xrad != yrad)
- doubleout(convPS(yrad));
+ if (xrad != yrad || VDPI != DPI)
+ doubleout(convVPS(yrad));
doubleout(degStAng);
doubleout(degEnAng);
- if (xrad == yrad) /* for arcs and circles */
+ if (xrad == yrad && VDPI == DPI) /* for arcs and circles */
cmdout("arc");
else
cmdout("ellipse");
@@ -461,7 +463,7 @@ void
flushSpline(char *cp)
{ /* as exact as psdit!!! */
register long i;
- register double dxi, dyi, dxi1, dyi1;
+ register double px, py, dx, dy;
if (*cp) {
double inchesPerDash;
@@ -498,23 +500,22 @@ flushSpline(char *cp)
doubleout(hconvPS(xx[1]));
doubleout(vconvPS(yy[1]));
cmdout(MOVETO);
- doubleout(convPS((xx[2]-xx[1])/2));
- doubleout(convPS((yy[2]-yy[1])/2));
+ px = convPS(xx[1]);
+ py = convVPS(yy[1]);
+ doubleout(dx = convPS((xx[2]+xx[1])/2) - px);
+ doubleout(dy = convVPS((yy[2]+yy[1])/2) - py);
cmdout(RLINETO);
for (i=2; i < pathLen; i++)
{
- dxi = convPS(xx[i] - xx[i-1]);
- dyi = convVPS(yy[i] - yy[i-1]);
- dxi1 = convPS(xx[i+1] - xx[i]);
- dyi1 = convVPS(yy[i+1] - yy[i]);
-
- doubleout(dxi/3);
- doubleout(dyi/3);
- doubleout((3*dxi+dxi1)/6);
- doubleout((3*dyi+dyi1)/6);
- doubleout((dxi+dxi1)/2);
- doubleout((dyi+dyi1)/2);
+ px += dx;
+ py += dy;
+ doubleout(convPS((xx[i-1]+5*xx[i])/6) - px);
+ doubleout(convVPS((yy[i-1]+5*yy[i])/6) - py);
+ doubleout(convPS((5*xx[i]+xx[i+1])/6) - px);
+ doubleout(convVPS((5*yy[i]+yy[i+1])/6) - py);
+ doubleout(dx = convPS((xx[i]+xx[i+1])/2) - px);
+ doubleout(dy = convVPS((yy[i]+yy[i+1])/2) - py);
cmdout(RCURVETO);
}
@@ -653,12 +654,11 @@ doShading(void)
*/
static double
zPixRound(register double x, /* in DVI units */
- register double convDPI /* dots per inch */
- ) /* return rounded number of pixels */
+ register double convDPI /* dots per inch */
+ ) /* return rounded number of pixels */
{
return ((x * mag * (double)convDPI /
(1000.0 * tpicRESOLUTION)));
}
#endif /* TPIC */
-
diff --git a/Build/source/texk/dvipsk/dvips.c b/Build/source/texk/dvipsk/dvips.c
index e03554540e3..34edae4ee1c 100644
--- a/Build/source/texk/dvipsk/dvips.c
+++ b/Build/source/texk/dvipsk/dvips.c
@@ -41,6 +41,11 @@ extern char *strtok(); /* some systems don't have this in strings.h */
#include descrip
#endif
#endif
+#ifdef __APPLE__ /* for Mac OS X, T. Uchiyama */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
#ifndef DEFRES
#define DEFRES (600)
@@ -58,6 +63,8 @@ extern char *strtok(); /* some systems don't have this in strings.h */
static char ofnme[252],infnme[252],pap[40],thh[20];
#endif
+Boolean SJIS; /* KANJI code encoding */
+
/* PS fonts fully downloaded as headers */
char *downloadedpsnames[DOWNLOADEDPSSIZE];
@@ -125,6 +132,7 @@ long bytesleft; /* number of bytes left in raster */
quarterword *raster; /* area for raster manipulations */
integer hh, vv; /* horizontal and vertical pixel positions */
Boolean noomega = 0; /* Omega extensions are enabled */
+Boolean noptex = 0; /* pTeX extensions are enabled */
/*-----------------------------------------------------------------------*
* The PATH definitions cannot be defined on the command line because so many
@@ -273,7 +281,8 @@ static const char *helparr[] = {
"-m* Manual feed -M* Don't make fonts",
"-mode s Metafont device name",
"-n # Maximum number of pages -N* No structured comments",
-"-noomega Disable Omega extensions",
+"-noomega Disable Omega and pTeX extensions",
+"-noptex Disable pTeX extensions",
"-o f Output file -O c Set/change paper offset",
#if defined(MSDOS) || defined(OS2)
"-p # First page -P s Load $s.cfg",
@@ -284,16 +293,17 @@ static const char *helparr[] = {
"-q* Run quietly",
"-r* Reverse order of pages -R* Run securely",
"-s* Enclose output in save/restore -S # Max section size in pages",
-"-t s Paper format -T c Specify desired page size",
+"-t s Paper format -T c Specify desired page size",
"-u s PS mapfile -U* Disable string param trick",
"-v Print version number and quit -V* Send downloadable PS fonts as PK",
"-x # Override dvi magnification -X # Horizontal resolution",
-"-y # Multiply by dvi magnification -Y # Vertical resolution",
+"-y # Multiply by dvi magnification -Y # Vertical resolution",
#ifdef HPS
"-z* Hyper PS -Z* Compress bitmap fonts",
#else
" -Z* Compress bitmap fonts",
#endif
+"-SJIS* Shift-JIS encoding",
/*"- Interactive query of options", */
" # = number f = file s = string * = suffix, `0' to turn off",
" c = comma-separated dimension pair (e.g., 3.2in,-32.1cm)",
@@ -464,6 +474,7 @@ initialize(void)
downloadedpsnames[i] = NULL;
unused_top_of_psnames = 0;
morestrings();
+ SJIS = 0;
maxpages = 100000;
numcopies = 1;
iname = fulliname = strings;
@@ -575,6 +586,17 @@ main(int argc, char **argv)
#endif
sectiontype *sects;
+#ifdef WIN32
+ SET_BINARY(fileno(stdin));
+ SET_BINARY(fileno(stdout));
+#endif
+
+#ifdef __APPLE__ /* for Mac OS X, T. Uchiyama */
+ struct rlimit rl;
+ getrlimit(RLIMIT_STACK, &rl);
+ rl.rlim_cur = 2048 * 1024;
+ setrlimit(RLIMIT_STACK, &rl);
+#endif
#ifdef KPATHSEA
kpse_set_program_name (argv[0], "dvips");
kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile);
@@ -789,10 +811,13 @@ case 'R':
secure_option = 1; /* Never used */
break;
case 'S':
- if (*p == 0 && argv[i+1])
- p = argv[++i];
- if (sscanf(p, "%d", &maxsecsize)==0)
- error("! Bad section size arg (-S).");
+ if (strncmp (p, "JIS", 3) == 0) SJIS = (*(p + 3) != '0');
+ else {
+ if (*p == 0 && argv[i+1])
+ p = argv[++i];
+ if (sscanf(p, "%d", &maxsecsize)==0)
+ error("! Bad section size arg (-S).");
+ }
break;
case 'm' :
if (STREQ (p, "ode") && argv[i+1]) {
@@ -803,7 +828,9 @@ case 'm' :
break;
case 'n' :
if (STREQ (p, "oomega")) {
- noomega = 1;
+ noomega = noptex = 1;
+ } else if (STREQ (p, "optex")) {
+ noptex = 1;
} else {
if (*p == 0 && argv[i+1])
p = argv[++i];
diff --git a/Build/source/texk/dvipsk/dvips.h b/Build/source/texk/dvipsk/dvips.h
index 4070f4d4955..74025cdb90f 100644
--- a/Build/source/texk/dvipsk/dvips.h
+++ b/Build/source/texk/dvipsk/dvips.h
@@ -8,6 +8,12 @@
/* This file is the header for dvips's global data structures. */
#define CREATIONDATE
+
+#define MAX_CODE 0x110000
+#define MAX_2BYTES_CODE 0x10000
+#define VF_MEM_UNIT 0x10000
+#define CD_IDX(i) ((i>=MAX_2BYTES_CODE ? MAX_2BYTES_CODE : i))
+
#define BANNER \
"This is dvips(k) 5.98dev Copyright 2010 Radical Eye Software"
#define BANNER2 "(www.radicaleye.com)"
@@ -57,9 +63,9 @@ extern char *sprintf();
#define STRINGSIZE (200000) /* maximum total chars in strings in program */
#define RASTERCHUNK (8192) /* size of chunk of raster */
#define MINCHUNK (240) /* minimum size char to get own raster */
-#define STACKSIZE (350) /* maximum stack size for dvi files */
-#define MAXFRAME (10) /* maximum depth of virtual font recursion */
-#define MAXFONTHD (100) /* number of unique names of included fonts */
+#define STACKSIZE (500) /* maximum stack size for dvi files */
+#define MAXFRAME (50) /* maximum depth of virtual font recursion */
+#define MAXFONTHD (1024) /* number of unique names of included fonts */
#define STDOUTSIZE (75) /* width of a standard output line */
#define DOWNLOADEDPSSIZE (1000) /* max number of downloaded fonts to check */
/*
@@ -164,7 +170,7 @@ typedef struct tcd {
* psfile. It can be 0, PREVPAGE, THISPAGE, or EXISTS.
*/
typedef struct tfd {
- integer checksum, scaledsize, designsize, thinspace;
+ integer checksum, scaledsize, designsize, thinspace, dir;
halfword dpi, loadeddpi;
halfword alreadyscaled;
halfword psname;
@@ -179,6 +185,7 @@ typedef struct tfd {
struct tfd *nextsize;
char *scalename;
chardesctype *chardesc;
+ int iswide;
} fontdesctype;
/* A fontmap associates a fontdesc with a font number.
@@ -322,12 +329,10 @@ struct papsiz {
#include <io.h>
#include <fcntl.h>
#define O_BINARY _O_BINARY
-#define popen _popen
-#define pclose _pclose
#define register
#define SET_BINARY(fd) _setmode((fd), _O_BINARY)
#else /* !WIN32 */
-#define SET_BINARY(fd)
+#define SET_BINARY(fd) 0
#endif
#if defined(DEVICESEP)
diff --git a/Build/source/texk/dvipsk/dvips.help b/Build/source/texk/dvipsk/dvips.help
index 3754ad97946..51636887d51 100644
--- a/Build/source/texk/dvipsk/dvips.help
+++ b/Build/source/texk/dvipsk/dvips.help
@@ -18,7 +18,8 @@ Options:
-m* Manual feed -M* Don't make fonts
-mode s Metafont device name
-n # Maximum number of pages -N* No structured comments
--noomega Disable Omega extensions
+-noomega Disable Omega and pTeX extensions
+-noptex Disable pTeX extensions
-o f Output file -O c Set/change paper offset
-p # First page -P s Load config.$s
-pp l Print only pages listed
diff --git a/Build/source/texk/dvipsk/finclude.c b/Build/source/texk/dvipsk/finclude.c
index 11e0252761f..5e21670d007 100644
--- a/Build/source/texk/dvipsk/finclude.c
+++ b/Build/source/texk/dvipsk/finclude.c
@@ -393,6 +393,7 @@ scanfontcomments(const char *filename)
* Allow scanning of ` commands. Better return same results both times.
*/
f = popen(filename+1, "r");
+ (void)SET_BINARY(fileno(f));
to_close = USE_PCLOSE;
} else {
f = search(figpath, filename, READ);
diff --git a/Build/source/texk/dvipsk/fontdef.c b/Build/source/texk/dvipsk/fontdef.c
index 254a43112cc..0da17216a9e 100644
--- a/Build/source/texk/dvipsk/fontdef.c
+++ b/Build/source/texk/dvipsk/fontdef.c
@@ -26,6 +26,7 @@ newfontdesc(integer cksum, integer scsize, integer dssize,
fp = (fontdesctype *)mymalloc((integer)sizeof(fontdesctype));
fp->chardesc = (chardesctype *)mymalloc(256*(integer)sizeof(chardesctype));
fp->maxchars = 256;
+ fp->iswide = 0;
fp->psname = 0;
fp->loaded = 0;
fp->checksum = cksum;
diff --git a/Build/source/texk/dvipsk/loadfont.c b/Build/source/texk/dvipsk/loadfont.c
index 0d96037534d..b64a68aeaa8 100644
--- a/Build/source/texk/dvipsk/loadfont.c
+++ b/Build/source/texk/dvipsk/loadfont.c
@@ -337,6 +337,7 @@ loadfont(register fontdesctype *curfnt)
tfmload(curfnt);
return;
}
+ curfnt->dir = 0;
if (!quiet) {
if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) {
fprintf(stderr, "\n");
diff --git a/Build/source/texk/dvipsk/output.c b/Build/source/texk/dvipsk/output.c
index 69e23d10cc4..c4822a3595b 100644
--- a/Build/source/texk/dvipsk/output.c
+++ b/Build/source/texk/dvipsk/output.c
@@ -21,22 +21,46 @@
#include <unistd.h> /* for `isatty' */
#endif
+/* UCS -> UTF-8 */
+#define UCStoUTF8B1(x) (0xc0 + (((x) >> 6) & 0x1f))
+#define UCStoUTF8B2(x) (0x80 + (((x) ) & 0x3f))
+
+#define UCStoUTF8C1(x) (0xe0 + (((x) >> 12) & 0x0f))
+#define UCStoUTF8C2(x) (0x80 + (((x) >> 6) & 0x3f))
+#define UCStoUTF8C3(x) (0x80 + (((x) ) & 0x3f))
+
+#define UCStoUTF8D1(x) (0xf0 + (((x) >> 18) & 0x07))
+#define UCStoUTF8D2(x) (0x80 + (((x) >> 12) & 0x3f))
+#define UCStoUTF8D3(x) (0x80 + (((x) >> 6) & 0x3f))
+#define UCStoUTF8D4(x) (0x80 + (((x) ) & 0x3f))
+
+/* UTF-32 over U+FFFF -> UTF-16 surrogate pair */
+#define UTF32toUTF16HS(x) (0xd800 + (((x-0x10000) >> 10) & 0x3ff))
+#define UTF32toUTF16LS(x) (0xdc00 + ( x & 0x3ff))
+
/*
* The external declarations:
*/
#include "protos.h"
char preamblecomment[256]; /* usually "TeX output ..." */
+integer rdir = 0, fdir = 0;
/*
* We need a few statics to take care of things.
*/
+static void chrcmd(char c);
+static void print_composefont(void);
+static void setdir(int d);
+static int JIStoSJIS(int c);
+
+static Boolean any_dir = 0; /* did we output any direction commands? */
+static Boolean jflag = 0;
static integer rhh, rvv;
static int instring;
static Boolean lastspecial = 1;
static shalfword d;
static Boolean popened = 0;
-int lastfont; /* exported to dospecial to fix rotate.tex problem */
-static void chrcmd(char c); /* just a forward declaration */
+static int lastfont;
static char strbuffer[LINELENGTH + 20], *strbp = strbuffer;
static struct papsiz *finpapsiz;
static struct papsiz defpapsiz = {
@@ -46,8 +70,10 @@ static struct papsiz defpapsiz = {
#if (!defined(VMS) && !defined(MSDOS) && !(defined(OS2) && defined(_MSC_VER)) && !defined(ATARIST))
/* VAXC/MSDOS don't like/need this !! */
#include <sys/types.h>
+#ifndef WIN32
#include <sys/time.h> /* time(), at least on BSD Unix */
#endif
+#endif
#include <time.h> /* asctime() and localtime(), at least on BSD Unix */
static time_t jobtime;
#endif
@@ -78,12 +104,7 @@ copyfile_general(const char *s, struct header_list *cur_header)
int scanningFont = 0;
/* end DOS EPS code */
-#ifdef VMCMS
- register char *lastdirsep;
- register char *trunc_s;
- trunc_s = s;
-#endif
-#ifdef MVSXA
+#if defined(VMCMS) || defined (MVSXA)
register char *lastdirsep;
register char *trunc_s;
trunc_s = s;
@@ -99,21 +120,19 @@ copyfile_general(const char *s, struct header_list *cur_header)
f = search(figpath, s, READBIN);
if (f == 0)
f = search(headerpath, s, READBIN);
-#ifdef VMCMS
+#if defined(VMCMS) || defined (MVSXA)
lastdirsep = strrchr(s, '/');
if ( NULL != lastdirsep ) trunc_s = lastdirsep + 1;
+#ifdef VMCMS
(void)sprintf(errbuf,
"Couldn't find figure file %s with CMS name %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s, trunc_s);
-#else
-#ifdef MVSXA
- lastdirsep = strrchr(s, '/');
- if ( NULL != lastdirsep ) trunc_s = lastdirsep + 1;
+#else /* VMCMS */
(void)sprintf(errbuf,
"Couldn't find figure file %s with MVS name %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s, trunc_s);
-#else
+#endif /* VMCMS */
+#else /* VMCMS || MVSXA */
(void)sprintf(errbuf, "Could not find figure file %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s);
-#endif
-#endif
+#endif /* VMCMS || MVSXA */
break;
#ifndef VMCMS
#ifndef MVSXA
@@ -169,15 +188,11 @@ copyfile_general(const char *s, struct header_list *cur_header)
fprintf(stderr, "\n");
prettycolumn = 0;
}
-#ifdef VMCMS
- (void)fprintf(stderr, "<%s>", trunc_s);
-#else
-#ifdef MVSXA
+#if defined(VMCMS) || defined (MVSXA)
(void)fprintf(stderr, "<%s>", trunc_s);
#else
(void)fprintf(stderr, "<%s>", realnameoffile);
#endif
-#endif
(void)fflush(stderr);
#if defined(VMCMS) || defined (MVSXA)
prettycolumn += 2 + strlen(s);
@@ -532,15 +547,11 @@ msdosdone:
c = '%';
}
}
-#ifdef VMCMS
- if (c != 0x37 || scanningFont) {
-#else
-#ifdef MVSXA
+#if defined(VMCMS) || defined (MVSXA)
if (c != 0x37 || scanningFont) {
#else
if (c != 4 || scanningFont) {
#endif
-#endif
if (!removingBytes)
(void)putc(c, bitfile);
}
@@ -698,6 +709,7 @@ scout(unsigned char c) /* string character out */
* need room for (, ), and a possible four-byte string \000, for
* instance. If it is too long, we send out the string.
*/
+ jflag = 0;
if (instring > LINELENGTH-6) {
stringend();
chrcmd('p');
@@ -715,13 +727,9 @@ scout(unsigned char c) /* string character out */
*strbp++ = '0' + (c & 7);
instring += 4;
} else {
-#ifdef VMCMS
- c = ascii2ebcdic[c];
-#else
-#ifdef MVSXA
+#if defined(VMCMS) || defined (MVSXA)
c = ascii2ebcdic[c];
#endif
-#endif
if (c == '(' || c == ')' || c == '\\') {
*strbp++ = '\\';
*strbp++ = c;
@@ -742,13 +750,52 @@ scout2(int c)
cmdout(s);
}
+static void
+jscout(int c, char *fs) /* string character out */
+{
+ char s[64];
+
+ if (!dir) {
+ numout(hh);
+ numout(vv);
+ } else {
+ numout(vv);
+ numout(-hh);
+ }
+ if (strstr(fs,"-UTF32-")!=NULL) {
+ sprintf(s, "a<%08x>p", c);
+ } else if (strstr(fs,"-UTF8-")!=NULL) {
+ if (c<0x80) {
+ sprintf(s, "a<%02x>p", c);
+ } else if (c<0x800) {
+ sprintf(s, "a<%02x%02x>p", UCStoUTF8B1(c), UCStoUTF8B2(c));
+ } else if (c<0xffff) {
+ sprintf(s, "a<%02x%02x%02x>p", UCStoUTF8C1(c), UCStoUTF8C2(c), UCStoUTF8C3(c));
+ } else if (c<0x10ffff) {
+ sprintf(s, "a<%02x%02x%02x%02x>p", UCStoUTF8D1(c), UCStoUTF8D2(c), UCStoUTF8D3(c), UCStoUTF8D4(c));
+ } else {
+ error("warning: Illegal code value.");
+ }
+ } else if (c>0xffff && strstr(fs,"-UTF16-")!=NULL) {
+ sprintf(s, "a<%04x%04x>p", UTF32toUTF16HS(c), UTF32toUTF16LS(c));
+ } else {
+ if ((strstr(fs,"-RKSJ-")!=NULL) || (SJIS && c > 0x2120)) c = JIStoSJIS(c);
+ sprintf(s, "a<%04x>p", c);
+ }
+ cmdout(s);
+ lastspecial = 1;
+ instring = 0;
+ jflag = 1;
+ strbuffer[0] = '\0';
+}
+
void
cmdout(const char *s)
{
int l;
/* hack added by dorab */
- if (instring) {
+ if (instring && !jflag) {
stringend();
chrcmd('p');
}
@@ -757,7 +804,6 @@ cmdout(const char *s)
linepos + l >= LINELENGTH) {
(void)putc('\n', bitfile);
linepos = 0;
- lastspecial = 1;
} else if (! lastspecial) {
(void)putc(' ', bitfile);
linepos++;
@@ -775,7 +821,6 @@ chrcmd(char c)
linepos + 2 > LINELENGTH) {
(void)putc('\n', bitfile);
linepos = 0;
- lastspecial = 1;
} else if (! lastspecial) {
(void)putc(' ', bitfile);
linepos++;
@@ -841,72 +886,111 @@ mhexout(register unsigned char *p,
}
}
-void
-fontout(int n)
+static void
+fontout(halfword n)
{
char buf[6];
- if (instring) {
+ if (instring && !jflag) {
stringend();
chrcmd('p');
}
makepsname(buf, n);
cmdout(buf);
+
+ lastfont = curfnt->psname;
}
void
hvpos(void)
{
- if (rvv != vv) {
- if (instring) {
- stringend();
- numout(hh);
- numout(vv);
- chrcmd('y');
- } else if (rhh != hh) {
- numout(hh);
- numout(vv);
- chrcmd('a');
- } else { /* hard to get this case, but it's there when you need it! */
- numout(vv - rvv);
- chrcmd('x');
- }
- rvv = vv;
- } else if (rhh != hh) {
- if (instring) {
- stringend();
- if (hh - rhh < 5 && rhh - hh < 5) {
-#ifdef VMCMS /* should replace 'p' in non-VMCMS line as well */
- chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]);
-#else
-#ifdef MVSXA /* should replace 'p' in non-MVSXA line as well */
- chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]);
+ if (!dir) {
+ if (rvv != vv || jflag) {
+ if (instring) {
+ stringend();
+ numout(hh);
+ numout(vv);
+ chrcmd('y');
+ } else if (rhh != hh) {
+ numout(hh);
+ numout(vv);
+ chrcmd('a');
+ } else { /* hard to get this case, but it's there when you need it! */
+ numout(vv - rvv);
+ chrcmd('x');
+ }
+ rvv = vv;
+ } else if (rhh != hh || jflag) {
+ if (instring) {
+ stringend();
+ if (hh - rhh < 5 && rhh - hh < 5) {
+#if defined(VMCMS) || defined (MVSXA) /* should replace 'p' in non-VMCMS, non-MVSXA line as well */
+ chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]);
#else
- chrcmd((char)('p' + hh - rhh));
-#endif
+ chrcmd((char)('p' + hh - rhh));
#endif
- } else if (hh - rhh < d + 5 && rhh - hh < 5 - d) {
-#ifdef VMCMS /* should replace 'g' in non-VMCMS line as well */
- chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]);
+ } else if (hh - rhh < d + 5 && rhh - hh < 5 - d) {
+#if defined(VMCMS) || defined (MVSXA) /* should replace 'g' in non-VMCMS, non-MVSXA line as well */
+ chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]);
#else
-#ifdef MVSXA /* should replace 'g' in non-MVSXA line as well */
- chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]);
+ chrcmd((char)('g' + hh - rhh - d));
+#endif
+ d = hh - rhh;
+ } else {
+ numout(hh - rhh);
+ chrcmd('b');
+ d = hh - rhh;
+ }
+ } else {
+ numout(hh - rhh);
+ chrcmd('w');
+ }
+ }
+ rhh = hh;
+ } else {
+ if (rhh != hh || jflag) {
+ if (instring) {
+ stringend();
+ numout(vv);
+ numout(-hh);
+ chrcmd('y');
+ } else if (rvv != vv) {
+ numout(vv);
+ numout(-hh);
+ chrcmd('a');
+ } else { /* hard to get this case, but it's there when you need it! */
+ numout(rhh - hh);
+ chrcmd('x');
+ }
+ rhh = hh;
+ } else if (rvv != vv || jflag) {
+ if (instring) {
+ stringend();
+ if (vv - rvv < 5 && rvv - vv < 5) {
+#if defined(VMCMS) || defined (MVSXA) /* should replace 'p' in non-VMCMS, non-MVSXA line as well */
+ chrcmd(ascii2ebcdic[(char)(112 + vv - rvv)]);
#else
- chrcmd((char)('g' + hh - rhh - d));
+ chrcmd((char)('p' + vv - rvv));
#endif
+ } else if (vv - rvv < d + 5 && rvv - vv < 5 - d) {
+#if defined(VMCMS) || defined (MVSXA) /* should replace 'g' in non-VMCMS, non-MVSXA line as well */
+ chrcmd(ascii2ebcdic[(char)(103 + vv - rvv - d)]);
+#else
+ chrcmd((char)('g' + vv - rvv - d));
#endif
- d = hh - rhh;
+ d = vv - rvv;
+ } else {
+ numout(vv - rvv);
+ chrcmd('b');
+ d = vv - rvv;
+ }
} else {
- numout(hh - rhh);
- chrcmd('b');
- d = hh - rhh;
+ numout(vv - rvv);
+ chrcmd('w');
}
- } else {
- numout(hh - rhh);
- chrcmd('w');
}
+ rvv = vv;
}
- rhh = hh;
}
/*
@@ -1190,22 +1274,7 @@ open_output(void) {
* point, and popen if so.
*/
if (*oname == '!' || *oname == '|') {
-#if defined (MSDOS) && !defined (__DJGPP__)
- error("! can't open output pipe");
-#else
-#ifdef VMS
- error("! can't open output pipe");
-#else
-#ifdef VMCMS
- error("! can't open output pipe");
-#else
-#ifdef MVSXA
- error("! can't open output pipe");
-#else
-#ifdef __THINK__
- error("! can't open output pipe");
-#else
-#ifdef ATARIST
+#if defined(MSDOS) && !defined(__DJGPP__) || defined(VMS) || defined(VMCMS) || defined(MVSXA) || defined(__THINK__) || defined(ATARIST)
error("! can't open output pipe");
#else
#ifdef OS2
@@ -1239,23 +1308,21 @@ open_output(void) {
&& !__dosexec_find_on_path(oname+1, environ, found))
pf = fopen("PRN", "w");
#endif
- if (pf == NULL && (pf = popen(oname+1, "w")) != NULL)
+ if (pf == NULL && (pf = popen(oname+1, "w")) != NULL) {
popened = 1;
+ (void)SET_BINARY(fileno(pf));
+ }
if (pf == NULL)
error("! couldn't open output pipe");
bitfile = pf;
#ifdef OS2
}
#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
+#endif /* MSDOS && !__DJGPP__ || VMS || ... */
} else {
if ((bitfile=fopen(oname,"w"))==NULL)
error("! couldn't open PostScript file");
+ (void)SET_BINARY(fileno(bitfile));
}
} else {
bitfile = stdout;
@@ -1362,26 +1429,19 @@ initprinter(sectiontype *sect)
(void)fprintf(bitfile, ", comments removed");
(void)fputc('\n', bitfile);
}
-#ifdef VMCMS /* convert preamblecomment to ebcdic so we can read it */
- {
- int i;
- for ( i=0; preamblecomment[i]; i++ )
- preamblecomment[i] = ascii2ebcdic[preamblecomment[i]];
- }
-#else
-#ifdef MVSXA /* IBM: MVS/XA */
+#if defined(VMCMS) || defined (MVSXA) /* convert preamblecomment to ebcdic so we can read it */
{
int i;
for ( i=0; preamblecomment[i]; i++ )
preamblecomment[i] = ascii2ebcdic[preamblecomment[i]];
}
-#endif /* VMCMS */
#endif
(void)fprintf(bitfile, "%%DVIPSSource: %s\n", preamblecomment);
linepos = 0;
endprologsent = 0;
if (safetyenclose)
(void)fprintf(bitfile, "/SafetyEnclosure save def\n");
+ print_composefont();
if (! headers_off)
send_headers();
}
@@ -1536,6 +1596,10 @@ pageend(void)
stringend();
chrcmd('p');
}
+ if (dir)
+ cmdout("-90 rotate");
+ if (any_dir)
+ cmdout("dyy");
cmdout("eop");
cmdout("end");
#ifdef HPS
@@ -1554,8 +1618,13 @@ pageend(void)
void
drawrule(integer rw, integer rh)
{
- numout((integer)hh);
- numout((integer)vv);
+ if (!dir) {
+ numout((integer)hh);
+ numout((integer)vv);
+ } else {
+ numout((integer)vv);
+ numout((integer)-hh);
+ }
if (rw == rulex && rh == ruley)
chrcmd('V');
else {
@@ -1573,14 +1642,49 @@ drawrule(integer rw, integer rh)
void
drawchar(chardesctype *c, int cc)
{
- hvpos();
- if (lastfont != curfnt->psname) {
- fontout((int)curfnt->psname);
- lastfont = curfnt->psname;
+ if (rdir != dir || fdir != curfnt->dir) {
+ if (curfnt->dir == 9)
+ setdir(dir+2);
+ else
+ setdir(dir);
+ rdir = dir;
+ fdir = curfnt->dir;
+ }
+
+ if (curfnt->iswide == 0 && curfnt->codewidth == 2) {
+ hvpos();
+ if (lastfont != curfnt->psname)
+ fontout(curfnt->psname);
+ scout2(cc);
+ }
+ else if (curfnt->iswide) {
+ if (lastfont != curfnt->psname)
+ fontout(curfnt->psname);
+ jscout(cc, curfnt->resfont->PSname);
+ }
+ else {
+ if (jflag) {
+ if (!dir){
+ numout(hh);
+ numout(vv);
+ }
+ else {
+ numout(vv);
+ numout(-hh);
+ }
+ chrcmd('a');
+ rhh = hh;
+ rvv = vv;
+ }
+ else hvpos();
+ if (lastfont != curfnt->psname)
+ fontout(curfnt->psname);
+ scout((unsigned char)cc);
}
- if (curfnt->codewidth==1) scout((unsigned char)cc);
- else scout2(cc);
- rhh = hh + c->pixelwidth; /* rvv = rv */
+ if (!dir)
+ rhh = hh + c->pixelwidth; /* rvv = rv */
+ else
+ rvv = vv + c->pixelwidth; /* rhh = rh */
}
/*
* This routine sends out the document fonts comment.
@@ -1608,3 +1712,86 @@ tell_needed_fonts(void) {
}
fprintf(bitfile, "\n");
}
+
+static void print_composefont(void)
+{
+ struct header_list *hl = ps_fonts_used;
+ int len;
+ char *q, *p;
+
+ if (hl == 0)
+ return;
+ while (0 != (q=get_name(&hl))) {
+ len = strlen(q);
+ if(len > 11 && (!strncmp(q+len-10, "Identity-H", 10) ||
+ !strncmp(q+len-10, "Identity-V", 10))) {
+ fprintf(bitfile, "%%%%BeginFont: %s\n", q);
+ fprintf(bitfile, "/%s ", q);
+ fprintf(bitfile, "/%s ", q+len-10);
+ fprintf(bitfile, "[/");
+ for(p=q; p <= q+len-12; p++)
+ fprintf(bitfile, "%c", *p);
+ fprintf(bitfile, "] composefont pop\n");
+ fprintf(bitfile, "%%%%EndFont\n");
+ }
+ }
+}
+
+static void setdir(int d)
+{
+ if (instring) {
+ stringend();
+ chrcmd('p');
+ }
+ switch(d) {
+ case 1 :
+ cmdout("dyt");
+ break;
+ case 2 :
+ cmdout("dty");
+ break;
+ case 3 :
+ cmdout("dtt");
+ break;
+ default :
+ cmdout("dyy");
+ break;
+ }
+ linepos += 4;
+ any_dir = 1;
+}
+
+void cmddir(void)
+{
+ if (dir != rdir) {
+ if (dir)
+ cmdout("90 rotate");
+ else
+ cmdout("-90 rotate");
+ rdir = dir;
+ }
+}
+
+static int JIStoSJIS(int c)
+{
+ int high, low;
+ int nh,nl;
+
+ high = (c>>8) & 0xff;
+ low = c & 0xff;
+ nh = ((high-0x21)>>1) + 0x81;
+ if (nh>0x9f)
+ nh += 0x40;
+ if (high & 1) {
+ nl = low + 0x1f;
+ if (low>0x5f)
+ nl++;
+ }
+ else
+ nl = low + 0x7e;
+ if (((nh >= 0x81 && nh <= 0x9f) || (nh >= 0xe0 && nh <= 0xfc)) &&
+ (nl >= 0x40 && nl <= 0xfc && nl != 0x7f))
+ return((nh<<8) | nl);
+ else
+ return(0x813f);
+}
diff --git a/Build/source/texk/dvipsk/pprescan.c b/Build/source/texk/dvipsk/pprescan.c
index b733365b3e9..f42af47abe5 100644
--- a/Build/source/texk/dvipsk/pprescan.c
+++ b/Build/source/texk/dvipsk/pprescan.c
@@ -57,9 +57,15 @@ pscanpage(void)
bopcolor(0);
while (1) {
switch (cmd=dvibyte()) {
-case 130: case 131: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255: /* unimplemented or illegal commands */
+case 255: /* pTeX's dir or undefined */
+ if (!noptex) {
+ (void)dvibyte();
+ break;
+ }
+/* illegal commands */
+case 131: case 136: case 139: /* set4, put4, bop */
+case 247: case 248: case 249: /* pre, post, post_post */
+case 250: case 251: case 252: case 253: case 254: /* undefined */
(void)sprintf(errbuf,
"! DVI file contains unexpected command (%d)",cmd);
error(errbuf);
@@ -83,7 +89,16 @@ case 143: case 148: case 153: case 157: case 162: case 167:
case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
case 138: case 141: case 142: /* nop, push, pop */
break;
-case 134: case 129: /* set2, put2 */
+case 130: case 135: /* set3, put3 */
+ if (noptex) {
+ (void)sprintf(errbuf,
+ "! DVI file contains unexpected pTeX command (%d)",cmd);
+ error(errbuf);
+ }
+ mychar = dvibyte(); mychar = (mychar << 8) + dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ goto dochar;
+case 129: case 134: /* set2, put2 */
if (noomega) {
(void)sprintf(errbuf,
"! DVI file contains unexpected Omega command (%d)",cmd);
@@ -91,9 +106,9 @@ case 134: case 129: /* set2, put2 */
}
mychar = dvibyte(); mychar = (mychar << 8) + dvibyte();
goto dochar;
-case 133: case 128: cmd = dvibyte(); /* set1, put1 commands drops through */
+case 128: case 133: cmd = dvibyte(); /* set1, put1 commands drops through */
default: /* these are commands 0 (setchar0) thru 127 (setchar 127) */
- mychar = cmd;
+ mychar = cmd;
dochar:
if (curfnt==NULL)
error("! Bad DVI file: no font selected");
@@ -109,8 +124,10 @@ dochar:
if (++frp == &frames[MAXFRAME] )
error("! virtual recursion stack overflow");
cd = curfnt->chardesc + mychar;
- if (cd->packptr == 0)
- error("! a non-existent virtual char is being used; check vf/tfm files");
+ if (cd->packptr == 0) {
+ fprintf(stderr, "Wrong char code: %04X\n", mychar);
+ error("! a non-existent virtual char is being used; check vf/tfm files");
+ }
curpos = cd->packptr + 2;
curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1)));
ffont = curfnt->localfonts;
@@ -199,8 +216,8 @@ pprescanpages(void)
if (ntfirst && mpagenum == firstpage && firstmatch == firstseq)
ntfirst = 0;
if (ntfirst ||
- ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) ||
- (pagelist && !InPageList(pagenum)))) {
+ ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) ||
+ (pagelist && !InPageList(pagenum)))) {
skipover(40);
skippage();
} else {
diff --git a/Build/source/texk/dvipsk/prescan.c b/Build/source/texk/dvipsk/prescan.c
index facdf9d7d08..e81e7299969 100644
--- a/Build/source/texk/dvipsk/prescan.c
+++ b/Build/source/texk/dvipsk/prescan.c
@@ -98,8 +98,8 @@ prescanpages(void)
if (ntfirst && mpagenum == firstpage && firstmatch == firstseq)
ntfirst = 0;
if (ntfirst ||
- ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) ||
- (pagelist && !InPageList(pagenum)))) {
+ ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) ||
+ (pagelist && !InPageList(pagenum)))) {
skipover(40);
skippage();
} else {
@@ -141,7 +141,7 @@ prescanpages(void)
*/
ret = 0;
while (maxpages>0) {
- if (!(evenpages && (pagenum & 1)) &&
+ if (!(evenpages && (pagenum & 1)) &&
!(oddpages && (pagenum & 1)==0) &&
!(pagelist && !InPageList(pagenum))) {
ret = scanpage();
@@ -149,7 +149,7 @@ prescanpages(void)
break;
pagecount++;
maxpages--;
- } else
+ } else
skippage();
thissectionmem = swmem - fontmem - OVERCOST;
mpagenum = abspage ? pageseq : pagenum;
diff --git a/Build/source/texk/dvipsk/protos.h b/Build/source/texk/dvipsk/protos.h
index 5c7c4300554..c9ec20a89e0 100644
--- a/Build/source/texk/dvipsk/protos.h
+++ b/Build/source/texk/dvipsk/protos.h
@@ -13,7 +13,6 @@ struct tcd;
/* prototypes for functions from bbox.c */
extern void bbtfmload(fontdesctype *curfnt);
-extern void bbspecial(int h, int v, int nbytes);
extern void bbdopage(void);
extern void findbb(int bop);
@@ -209,7 +208,6 @@ extern void floatout(float n);
extern void doubleout(double n);
extern void numout(int n);
extern void mhexout(unsigned char *p, long len);
-extern void fontout(int n);
extern void hvpos(void);
extern void newline(void);
extern void nlcmdout(const char *s);
@@ -226,6 +224,7 @@ extern void psflush(void);
extern void pageinit(void);
extern void pageend(void);
extern void drawrule(int rw, int rh);
+extern void cmddir(void);
extern void drawchar(chardesctype * c, int cc);
extern void tell_needed_fonts(void);
@@ -373,6 +372,7 @@ extern boolean t1_subset_2(char *, unsigned char *, char *);
/*********** global variables ***********/
/* global variables from dopage.c */
+extern integer dir;
#ifdef HPS
extern integer hhmem, vvmem;
extern integer pushcount;
@@ -386,6 +386,7 @@ extern int pagecounter;
#endif
/* global variables from dvips.c */
+extern Boolean SJIS;
extern char *downloadedpsnames[];
extern int unused_top_of_psnames;
extern fontdesctype *fonthead;
@@ -443,6 +444,7 @@ extern long bytesleft;
extern quarterword *raster;
extern integer hh, vv;
extern Boolean noomega;
+extern Boolean noptex;
extern const char *infont;
#ifndef KPATHSEA
extern char *tfmpath;
@@ -525,6 +527,7 @@ extern FILE *pkfile;
/* global variables from output.c */
extern char preamblecomment[256];
+extern integer rdir, fdir;
/* global variables from pprescan.c */
extern Boolean pprescan;
diff --git a/Build/source/texk/dvipsk/protos_add.h b/Build/source/texk/dvipsk/protos_add.h
index 59d5c7e3b65..22bd4393adb 100644
--- a/Build/source/texk/dvipsk/protos_add.h
+++ b/Build/source/texk/dvipsk/protos_add.h
@@ -12,7 +12,7 @@
/* global variables from dopage.c */
extern struct dvistack {
integer hh, vv;
- integer h, v, w, x, y, z;
+ integer h, v, w, x, y, z, dir;
} stack[];
/* global variables from loadfont.c */
diff --git a/Build/source/texk/dvipsk/repack.c b/Build/source/texk/dvipsk/repack.c
index b8c4afa58e3..77382bcc89f 100644
--- a/Build/source/texk/dvipsk/repack.c
+++ b/Build/source/texk/dvipsk/repack.c
@@ -422,7 +422,7 @@ repack(register chardesctype *cp)
mraster[--i] = 0;
i = startbytes + unpack(p, (halfword *)mraster, (halfword)width,
(halfword)height, *(cp->packptr));
- dochar(mraster, (width + 7) >> 3, height);
+ dochar(mraster, (short)((width + 7) >> 3), (short)height);
if (smallchar) {
addts((unsigned char)0);
addts((unsigned char)0);
diff --git a/Build/source/texk/dvipsk/resident.c b/Build/source/texk/dvipsk/resident.c
index 3b2054ae2da..17ade0b6534 100644
--- a/Build/source/texk/dvipsk/resident.c
+++ b/Build/source/texk/dvipsk/resident.c
@@ -40,10 +40,10 @@ struct header_list *ps_fonts_used;
unsigned int
hash(char *s)
{
- unsigned h = 12;
+ unsigned int h = 12;
while (*s != 0)
- h = (h + h + *s++) % RESHASHPRIME;
+ h = (h + h + (unsigned char)(*s++)) % RESHASHPRIME;
return(h);
}
/*
@@ -101,7 +101,7 @@ findPSname(char *name)
*/
void
add_entry(char *TeXname, char *PSname, char *Fontfile,
- char *Vectfile, char *specinfo, char *downloadinfo)
+ char *Vectfile, char *specinfo, char *downloadinfo)
{
struct resfont *p;
int h;
@@ -320,10 +320,10 @@ getdefaults(const char *s)
/* $DVIPSRC was set by user */
strcpy(PSname, dvipsrc);
}
- else
+ else
/* No env var, looking into some kind of standard path. */
if (SearchPath(".;%HOME%;c:\\", ".dvipsrc", NULL,
- INLINE_SIZE, PSname,
+ INLINE_SIZE, PSname,
&dvipsrc) == 0) {
/* search failed, we must put something into PSname. */
dvipsrc = kpse_var_expand(DVIPSRC);
@@ -334,10 +334,10 @@ getdefaults(const char *s)
/* Else SearchPath has filled PSname with something */
}
/* remove any redundant path separators. Many configurations
- can show up: c:\/.dvipsrc and so on ... */
- {
+ can show up: c:\/.dvipsrc and so on ... */
+ {
char *p, *q;
- for (p = q = PSname; *p && (p - PSname < INLINE_SIZE);
+ for (p = q = PSname; *p && (p - PSname < INLINE_SIZE);
p++, q++) {
if (IS_DIR_SEP(*p)) {
*q = DIR_SEP; p++; q++;
@@ -352,7 +352,7 @@ getdefaults(const char *s)
strcpy(PSname, dvipsrc ? dvipsrc : "~/.dvipsrc");
if(dvipsrc) free(dvipsrc);
#endif /* WIN32 */
-
+
#else /* ! KPATHSEA */
#ifndef VMCMS /* IBM: VM/CMS - don't have home directory on VMCMS */
#ifndef MVSXA
@@ -436,7 +436,7 @@ case '@' :
} else {
struct papsiz *ps;
char *q;
-
+
ps = (struct papsiz *)mymalloc((integer)sizeof(struct papsiz));
ps->next = papsizes;
papsizes = ps;
@@ -458,10 +458,10 @@ case 'a' :
break;
case 'b':
#ifdef SHORTINT
- if (sscanf(was_inline+1, "%ld", &pagecopies) != 1)
+ if (sscanf(was_inline+1, "%ld", &pagecopies) != 1)
bad_config("missing pagecopies to b");
#else
- if (sscanf(was_inline+1, "%d", &pagecopies) != 1)
+ if (sscanf(was_inline+1, "%d", &pagecopies) != 1)
bad_config("missing pagecopies to b");
#endif
if (pagecopies < 1 || pagecopies > 1000)
@@ -469,7 +469,7 @@ case 'b':
break;
case 'm' :
#ifdef SHORTINT
- if (sscanf(was_inline+1, "%ld", &swmem) != 1)
+ if (sscanf(was_inline+1, "%ld", &swmem) != 1)
bad_config("missing swmem to m");
#else /* ~SHORTINT */
if (sscanf(was_inline+1, "%d", &swmem) != 1)
@@ -517,7 +517,7 @@ case 'O' :
handlepapersize(p, &hoff, &voff);
break;
#ifdef FONTLIB
-case 'L' :
+case 'L' :
{
char tempname[INLINE_SIZE];
if (sscanf(was_inline+1, "%s", PSname) != 1) bad_config("missing arg to L");
@@ -528,7 +528,7 @@ case 'L' :
}
break;
#endif
-case 'T' :
+case 'T' :
if (sscanf(was_inline+1, "%s", PSname) != 1)
bad_config("missing arg to T");
else
@@ -540,7 +540,7 @@ case 'T' :
break;
case 'P' :
if (sscanf(was_inline+1, "%s", PSname) != 1) bad_config("missing arg to P");
- else
+ else
#ifdef KPATHSEA
SET_CLIENT_PATH (kpse_pk_format, PSname);
#else
@@ -560,9 +560,9 @@ case 'p' :
}
break;
case 'v' : case 'V' :
- if (sscanf(was_inline+1, "%s", PSname) != 1)
+ if (sscanf(was_inline+1, "%s", PSname) != 1)
bad_config("missing arg to V");
- else
+ else
#ifdef KPATHSEA
SET_CLIENT_PATH (kpse_vf_format, PSname);
#else
@@ -570,8 +570,10 @@ case 'v' : case 'V' :
#endif
break;
case 'S' :
- if (sscanf(was_inline+1, "%s", PSname) != 1)
- bad_config("missing arg to S");
+ if (!strncmp(was_inline, "SJIS", 4))
+ SJIS = (was_inline[4] != '0');
+ else if (sscanf(was_inline+1, "%s", PSname) != 1)
+ bad_config("missing arg to S");
else
#ifdef KPATHSEA
SET_CLIENT_PATH (kpse_pict_format, PSname);
@@ -582,10 +584,10 @@ case 'S' :
case 's':
safetyenclose = 1;
break;
-case 'H' :
- if (sscanf(was_inline+1, "%s", PSname) != 1)
+case 'H' :
+ if (sscanf(was_inline+1, "%s", PSname) != 1)
bad_config("missing arg to H");
- else
+ else
#ifdef KPATHSEA
SET_CLIENT_PATH (headerpath, PSname);
#else
@@ -689,7 +691,7 @@ case 'Y' :
bad_config("Y arg must be between 10 and 10000");
break;
case 'x': case 'y':
- if (sscanf(was_inline+1, "%lg", &mag) != 1)
+ if (sscanf(was_inline+1, "%lg", &mag) != 1)
bad_config("missing arg to x or y");
overridemag = (was_inline[0] == 'x') ? 1 : -1;
break;
@@ -699,7 +701,7 @@ case 'e' :
if (maxdrift < 0) bad_config("bad argument to e");
vmaxdrift = maxdrift;
break;
-case 'z' :
+case 'z' :
if (secure_option && secure && was_inline[1] == '0') {
fprintf (stderr,
"warning: %s: z0 directive ignored since -R1 given\n",
@@ -729,7 +731,7 @@ case 'G':
shiftlowchars = (was_inline[1] != '0');
break;
#endif
-case 'h' :
+case 'h' :
if (sscanf(was_inline+1, "%s", PSname) != 1)
bad_config("missing arg to h");
else (void)add_header(PSname);
@@ -779,7 +781,7 @@ default:
return 0;
}
}
-
+
return 1;
}
@@ -852,7 +854,7 @@ getpsinfo(const char *name)
/* skip whitespace after < */
while (*p && *p <= ' ')
p++;
-
+
/* save start of header name */
hdr_name = p;
@@ -1014,13 +1016,13 @@ char *
xmalloc(unsigned size)
{
char *mem = malloc (size);
-
+
if (mem == NULL)
{
fprintf (stderr, "! Cannot allocate %u bytes.\n", size);
exit (10);
}
-
+
return mem;
}
@@ -1029,31 +1031,31 @@ char *
xrealloc(char *ptr, unsigned size)
{
char *mem = realloc (ptr, size);
-
+
if (mem == NULL)
{
fprintf (stderr, "! Cannot reallocate %u bytes at %x.\n", size, (int)ptr);
exit (10);
}
-
+
return mem;
}
/* Return, in NAME, the next component of PATH, i.e., the characters up
to the next PATHSEP. */
-
+
static void
next_component(char *name, char **path)
{
unsigned count = 0;
-
+
while (**path != 0 && **path != PATHSEP)
{
name[count++] = **path;
(*path)++; /* Move further along, even between calls. */
}
-
+
name[count] = 0;
if (**path == PATHSEP)
(*path)++; /* Move past the delimiter. */
@@ -1092,7 +1094,7 @@ concat3(char *s1, char *s2, char *s3)
/* DIR_LIST is the default list of directories (colon-separated) to
search. We want to add all the subdirectories directly below each of
the directories in the path.
-
+
We return the list of directories found. */
char *
@@ -1110,7 +1112,7 @@ do_subdir_path(char *dir_list)
/* Make a copy in writable memory. */
dir_list = xmalloc (strlen (temp) + 1);
strcpy (dir_list, temp);
-
+
*result = 0;
/* Unfortunately, we can't look in the environment for the current
@@ -1177,7 +1179,7 @@ do_subdir_path(char *dir_list)
}
}
while (*dir_list != 0);
-
+
return result;
}
#endif /* SEARCH_SUBDIRECTORIES */
diff --git a/Build/source/texk/dvipsk/scanpage.c b/Build/source/texk/dvipsk/scanpage.c
index 8cdf38d3b6b..38e6a897b1b 100644
--- a/Build/source/texk/dvipsk/scanpage.c
+++ b/Build/source/texk/dvipsk/scanpage.c
@@ -133,9 +133,15 @@ scanpage(void)
while (1) {
switch (cmd=dvibyte()) {
-case 130: case 131: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255: /* unimplemented or illegal commands */
+case 255: /* pTeX's dir or undefined */
+ if (!noptex) {
+ (void)dvibyte();
+ break;
+ }
+/* illegal commands */
+case 131: case 136: case 139: /* set4, put4, bop */
+case 247: case 248: case 249: /* pre, post, post_post */
+case 250: case 251: case 252: case 253: case 254: /* undefined */
(void)sprintf(errbuf,
"! DVI file contains unexpected command (%d)",cmd);
error(errbuf);
@@ -159,7 +165,16 @@ case 143: case 148: case 153: case 157: case 162: case 167:
case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
case 138: case 141: case 142: /* nop, push, pop */
break;
-case 134: case 129: /* set2, put2 */
+case 130: case 135: /* set3, put3 */
+ if (noptex) {
+ (void)sprintf(errbuf,
+ "! DVI file contains unexpected pTeX command (%d)",cmd);
+ error(errbuf);
+ }
+ mychar = dvibyte(); mychar = (mychar << 8) + dvibyte();
+ mychar = (mychar << 8) + dvibyte();
+ goto dochar;
+case 129: case 134: /* set2, put2 */
if (noomega) {
(void)sprintf(errbuf,
"! DVI file contains unexpected Omega command (%d)",cmd);
@@ -167,9 +182,9 @@ case 134: case 129: /* set2, put2 */
}
mychar = dvibyte(); mychar = (mychar << 8) + dvibyte();
goto dochar;
-case 133: case 128: cmd = dvibyte(); /* set1 commands drops through */
+case 128: case 133: cmd = dvibyte(); /* set1, put1 commands drops through */
default: /* these are commands 0 (setchar0) thru 127 (setchar 127) */
- mychar = cmd;
+ mychar = cmd;
dochar:
/*
* We are going to approximate that each string of consecutive characters
@@ -189,8 +204,10 @@ dochar:
if (++frp == &frames[MAXFRAME] )
error("! virtual recursion stack overflow");
cd = curfnt->chardesc + mychar;
- if (cd->packptr == 0)
- error("! a non-existent virtual character is being used; check vf/tfm files");
+ if (cd->packptr == 0) {
+ fprintf(stderr, "Wrong char code: %04X\n", mychar);
+ error("! a non-existent virtual character is being used; check vf/tfm files");
+ }
curpos = cd->packptr + 2;
curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1)));
ffont = curfnt->localfonts;
diff --git a/Build/source/texk/dvipsk/search.c b/Build/source/texk/dvipsk/search.c
index df08033240b..7259b8ef445 100644
--- a/Build/source/texk/dvipsk/search.c
+++ b/Build/source/texk/dvipsk/search.c
@@ -146,6 +146,7 @@ search(kpse_file_format_type format, const char *file, const char *mode)
char *prog = selfautoloc_prog (GUNZIP);
cmd = concat3 (prog, " -c ", quoted_name);
ret = popen (cmd, "r");
+ (void)SET_BINARY(fileno(ret));
to_close = USE_PCLOSE;
free (cmd);
free (quoted_name);
diff --git a/Build/source/texk/dvipsk/skippage.c b/Build/source/texk/dvipsk/skippage.c
index 6f9f6622b15..3af8bc7fd7e 100644
--- a/Build/source/texk/dvipsk/skippage.c
+++ b/Build/source/texk/dvipsk/skippage.c
@@ -31,10 +31,14 @@ skippage(void)
bopcolor(0);
while ((cmd=dvibyte())!=140) {
switch (cmd) {
-/* illegal options */
-case 130: case 131: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251:
-case 252: case 253: case 254: case 255:
+case 255: /* pTeX's dir or undefined */
+ if (!noptex) {
+ cmd = dvibyte();
+ break;
+ }
+/* illegal commands */
+case 139: case 247: case 248: case 249: /* bop, pre, post, post_post */
+case 250: case 251: case 252: case 253: case 254: /* undefined */
(void)sprintf(errbuf,
"! DVI file contains unexpected command (%d)",cmd);
error(errbuf);
@@ -45,18 +49,20 @@ case 132: case 137:
cmd = dvibyte();
cmd = dvibyte();
/* four byte commands */
+case 131: case 136:
case 146: case 151: case 156: case 160: case 165: case 170: case 238:
cmd = dvibyte();
/* three byte commands */
+case 130: case 135:
case 145: case 150: case 155: case 159: case 164: case 169: case 237:
cmd = dvibyte();
/* two byte commands */
-case 129: case 134: case 144: case 149: case 154: case 158: case 163:
-case 168: case 236:
+case 129: case 134:
+case 144: case 149: case 154: case 158: case 163: case 168: case 236:
cmd = dvibyte();
/* one byte commands */
-case 128: case 133: case 143: case 148: case 153: case 157: case 162:
-case 167: case 235:
+case 128: case 133:
+case 143: case 148: case 153: case 157: case 162: case 167: case 235:
cmd = dvibyte();
break;
/* specials */
diff --git a/Build/source/texk/dvipsk/tex.lpro b/Build/source/texk/dvipsk/tex.lpro
index 2b92d6ba5bc..b7cc3deebe7 100644
--- a/Build/source/texk/dvipsk/tex.lpro
+++ b/Build/source/texk/dvipsk/tex.lpro
@@ -258,7 +258,22 @@ TeXDict begin % start using it.
65781.76 div /hsize X
} N
-/p {show} N % the main character setting routine
+/dir 0 def
+/dyy {/dir 0 def
+} B
+/dyt {/dir 1 def
+} B
+/dty {/dir 2 def
+} B
+/dtt {/dir 3 def
+} B
+
+%/p {show} N % the main character setting routine
+/p {dir 2 eq
+ {-90 rotate show 90 rotate}
+ {dir 3 eq {-90 rotate show 90 rotate}
+ {show} ifelse} ifelse
+} N
/RMat [ 1 0 0 -1 0 0 ] N % things we need for rules
/BDot 260 string N
diff --git a/Build/source/texk/dvipsk/tfmload.c b/Build/source/texk/dvipsk/tfmload.c
index 5b9ed411c4c..d3d9b7ce958 100644
--- a/Build/source/texk/dvipsk/tfmload.c
+++ b/Build/source/texk/dvipsk/tfmload.c
@@ -11,7 +11,7 @@
*/
#include "protos.h"
-FILE *tfmfile;
+FILE *tfmfile;
/*
* Our static variables:
@@ -32,9 +32,9 @@ badtfm(const char *s)
void
tfmopen(register fontdesctype *fd)
{
- register char *n;
+ register char *n;
#ifdef KPATHSEA
- kpse_file_format_type d;
+ kpse_file_format_type d;
#else
register char *d;
#endif
@@ -85,25 +85,25 @@ tfmopen(register fontdesctype *fd)
shalfword
tfmbyte(void)
{
- return(getc(tfmfile));
+ return(getc(tfmfile));
}
halfword
tfm16(void)
{
- register halfword a;
- a = tfmbyte ();
- return ( a * 256 + tfmbyte () );
-}
+ register halfword a;
+ a = tfmbyte ();
+ return ( a * 256 + tfmbyte () );
+}
integer
tfm32(void)
{
- register integer a;
- a = tfm16 ();
- if (a > 32767) a -= 65536;
- return ( a * 65536 + tfm16 () );
-}
+ register integer a;
+ a = tfm16 ();
+ if (a > 32767) a -= 65536;
+ return ( a * 65536 + tfm16 () );
+}
int
tfmload(register fontdesctype *curfnt)
@@ -111,9 +111,12 @@ tfmload(register fontdesctype *curfnt)
register integer i, j;
register integer li, cd=0;
integer scaledsize;
+ integer id, nt = 0;
integer nw, hd;
integer bc, ec;
integer nco=0, ncw=0, npc=0, no_repeats = 0;
+ halfword *index = NULL;
+ halfword *chartype = NULL;
integer *scaled;
integer *chardat;
int font_level;
@@ -125,14 +128,32 @@ tfmload(register fontdesctype *curfnt)
* Next, we read the font data from the tfm file, and store it in
* our own arrays.
*/
- li = tfm16();
- if (li!=0) {
+ curfnt->dir = 0;
+ curfnt->iswide = 0;
+ curfnt->codewidth = 1;
+ id = tfm16();
+ if (id!=0) {
font_level = -1;
+ if (id == 9 || id == 11) {
+ if (noptex) badtfm("length");
+ if (id == 9) curfnt->dir = id;
+ nt = tfm16(); li = tfm16();
+ curfnt->iswide = 1;
+ curfnt->maxchars = MAX_CODE;
+ curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc,
+ sizeof(chardesctype)*(MAX_CODE));
+ for (i=0; i<MAX_CODE; i++) {
+ curfnt->chardesc[i].TFMwidth = 0;
+ curfnt->chardesc[i].packptr = NULL;
+ curfnt->chardesc[i].pixelwidth = 0;
+ curfnt->chardesc[i].flags = 0;
+ }
+ }
hd = tfm16();
bc = tfm16(); ec = tfm16();
nw = tfm16();
li = tfm32(); li = tfm32(); li = tfm32(); li = tfm16();
- if (hd<2 || bc>ec+1 || ec>255 || nw>256)
+ if ((hd<2 || bc>ec+1 || ec>255 || nw>256) && id != 9 && id != 11)
badtfm("header");
} else { /* In an .ofm file */
if (noomega) badtfm("length");
@@ -154,58 +175,83 @@ tfmload(register fontdesctype *curfnt)
li = tfm32();
check_checksum (li, curfnt->checksum, curfnt->name);
li = (integer)(alpha * (real)tfm32());
- if (li > curfnt->designsize + fsizetol
- || li < curfnt->designsize - fsizetol) {
+ if (li > curfnt->designsize + fsizetol ||
+ li < curfnt->designsize - fsizetol) {
char *msg = concat ("Design size mismatch in font ", curfnt->name);
error(msg);
}
pretend_no_chars=ec+1;
- if (pretend_no_chars<256) pretend_no_chars=256;
- else {
- curfnt->chardesc = (chardesctype *)
- xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars);
- curfnt->maxchars = pretend_no_chars;
- }
- for (i=2; i<((font_level==1)?nco-29:hd); i++)
- li = tfm32();
- chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer));
- for (i=0; i<pretend_no_chars; i++)
- chardat[i] = -1;
- for (i=bc; i<=ec; i++) {
- if (no_repeats>0) {
- no_repeats--;
- } else if (font_level>=0) {
- cd = tfm16();
+ if (id == 9 || id == 11) {
+ chardat = (integer *)xmalloc(256*sizeof(integer));
+ for (i=2; i<hd; i++)
li = tfm32();
+ index = (halfword *)malloc(nt * sizeof(halfword));
+ chartype = (halfword *)malloc(nt * sizeof(halfword));
+ li = tfm16();
+ li = tfm16();
+ for (i=1; i<nt; i++) {
+ index[i] = tfm16();
+ chartype[i] = tfm16();
+ }
+ for (i=0; i<256; i++)
+ chardat[i] = 256;
+
+ for (i=bc; i<=ec; i++) {
+ chardat[i] = tfmbyte();
li = tfm16();
- if (font_level==1) {
- no_repeats = tfm16();
- for (j=0; j<(npc|1); j++) tfm16();
- ncw -= 3 + npc/2;
+ li |= tfmbyte();
+ if (li || chardat[i])
+ charcount++;
+ }
+ } else {
+ if (pretend_no_chars<=256) pretend_no_chars=256;
+ else {
+ curfnt->chardesc = (chardesctype *)
+ xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars);
+ curfnt->maxchars = pretend_no_chars;
+ }
+ for (i=2; i<((font_level==1)?nco-29:hd); i++)
+ li = tfm32();
+ chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer));
+ for (i=0; i<pretend_no_chars; i++)
+ chardat[i] = -1;
+ for (i=bc; i<=ec; i++) {
+ if (no_repeats>0) {
+ no_repeats--;
+ } else if (font_level>=0) {
+ cd = tfm16();
+ li = tfm32();
+ li = tfm16();
+ if (font_level==1) {
+ no_repeats = tfm16();
+ for (j=0; j<(npc|1); j++) tfm16();
+ ncw -= 3 + npc/2;
+ }
+ } else {
+ cd = tfmbyte();
+ li = tfm16();
+ li = tfmbyte();
+ }
+ if (cd>=nw) badtfm("char info");
+ if (cd) {
+ chardat[i] = cd;
+ charcount++;
}
- } else {
- cd = tfmbyte();
- li = tfm16();
- li = tfmbyte();
}
- if (cd>=nw) badtfm("char info");
- if (cd) {
- chardat[i] = cd;
- charcount++;
+ if (font_level==1&&ncw!=0) {
+ char *msg = concat ("Table size mismatch in ", curfnt->name);
+ error(msg);
}
}
- if (font_level==1&&ncw!=0) {
- char *msg = concat ("Table size mismatch in ", curfnt->name);
- error(msg);
- }
scaledsize = curfnt->scaledsize;
scaled = (integer *) xmalloc(nw*sizeof(integer));
for (i=0; i<nw; i++)
scaled[i] = scalewidth(tfm32(), scaledsize);
(void)fclose(tfmfile);
- for (i=0; i<pretend_no_chars; i++)
- if (chardat[i]!= -1) {
- li = scaled[chardat[i]];
+
+ if (id == 9 || id == 11) {
+ for (i=0; i<MAX_CODE; i++) {
+ li = scaled[chardat[0]];
curfnt->chardesc[i].TFMwidth = li;
if (li >= 0)
curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5));
@@ -213,10 +259,33 @@ tfmload(register fontdesctype *curfnt)
curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5));
curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0);
curfnt->chardesc[i].flags2 = EXISTS;
- } else curfnt->chardesc[i].flags = curfnt->chardesc[i].flags2 = 0;
+ }
+ for (i=1; i<nt; i++) {
+ li = scaled[chardat[chartype[i]]];
+ curfnt->chardesc[index[i]].TFMwidth = li;
+ if (li >= 0)
+ curfnt->chardesc[index[i]].pixelwidth = ((integer)(conv*li+0.5));
+ else
+ curfnt->chardesc[index[i]].pixelwidth = -((integer)(conv*-li+0.5));
+ }
+ free(index);
+ free(chartype);
+ } else {
+ for (i=0; i<pretend_no_chars; i++)
+ if (chardat[i]!= -1) {
+ li = scaled[chardat[i]];
+ curfnt->chardesc[i].TFMwidth = li;
+ if (li >= 0)
+ curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5));
+ else
+ curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5));
+ curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0);
+ curfnt->chardesc[i].flags2 = EXISTS;
+ }
+ if (ec>=256) curfnt->codewidth = 2; /* XXX: 2byte-code can have ec<256 */
+ }
free(chardat);
free(scaled);
- if (ec>=256) curfnt->codewidth = 2; /* XXX: 2byte-code can have ec<256 */
curfnt->loaded = 1;
return charcount;
}
diff --git a/Build/source/texk/dvipsk/virtualfont.c b/Build/source/texk/dvipsk/virtualfont.c
index ab47e5134a3..4319c047946 100644
--- a/Build/source/texk/dvipsk/virtualfont.c
+++ b/Build/source/texk/dvipsk/virtualfont.c
@@ -148,7 +148,7 @@ vfontdef(integer s, int siz)
Boolean
virtualfont(register fontdesctype *curfnt)
{
- register integer i;
+ register integer i, j;
register shalfword cmd;
register integer k;
register integer length;
@@ -160,7 +160,7 @@ virtualfont(register fontdesctype *curfnt)
register quarterword *tempr;
fontmaptype *fm, *newf;
int kindfont;
- kindfont = vfopen(curfnt); /* 1 for TeX, 2 for Omega */
+ kindfont = vfopen(curfnt); /* 1 for TeX and pTeX, 2 for Omega */
if (!kindfont)
return (0);
#ifdef DEBUG
@@ -173,11 +173,11 @@ virtualfont(register fontdesctype *curfnt)
* We clear out some pointers:
*/
if (kindfont==2) {
- no_of_chars = 65536;
- curfnt->maxchars=65536;
- free(curfnt->chardesc);
- curfnt->chardesc = (chardesctype *)
- mymalloc(65536 * (integer)sizeof(chardesctype));
+ no_of_chars = VF_MEM_UNIT;
+ curfnt->maxchars=VF_MEM_UNIT;
+ free(curfnt->chardesc);
+ curfnt->chardesc = (chardesctype *)
+ mymalloc(VF_MEM_UNIT * (integer)sizeof(chardesctype));
}
for (i=0; i<no_of_chars; i++) {
curfnt->chardesc[i].TFMwidth = 0;
@@ -196,9 +196,17 @@ virtualfont(register fontdesctype *curfnt)
check_checksum (k, curfnt->checksum, curfnt->name);
k = (integer)(alpha * (real)vfquad());
if (k > curfnt->designsize + 2 || k < curfnt->designsize - 2) {
- char *msg = concat("Design size mismatch in font ", name);
- error(msg);
- free(msg);
+ int id = 0;
+ if (!noptex) {
+ tfmopen(curfnt); /* We check if parent is jfm or not. */
+ id = tfm16();
+ (void)fclose(tfmfile);
+ }
+ if (id != 9 && id != 11) {
+ char *msg = concat("Design size mismatch in font ", name);
+ error(msg);
+ free(msg);
+ }
}
/*
* Now we look for font definitions.
@@ -223,7 +231,21 @@ virtualfont(register fontdesctype *curfnt)
if (length<2) badvf("negative length packet");
if (length>65535) badvf("packet too long");
cc = vfquad();
- if (cc<0 || cc>=no_of_chars) badvf("character code out of range");
+ if (cc>=no_of_chars && cc<MAX_CODE) {
+ j = VF_MEM_UNIT * ((integer)(cc/VF_MEM_UNIT) + 1);
+ curfnt->chardesc = (chardesctype *)xrealloc(curfnt->chardesc,
+ sizeof(chardesctype)*j);
+ for (i=no_of_chars; i<j; i++) {
+ curfnt->chardesc[i].TFMwidth = 0;
+ curfnt->chardesc[i].packptr = NULL;
+ curfnt->chardesc[i].pixelwidth = 0;
+ curfnt->chardesc[i].flags = 0;
+ curfnt->chardesc[i].flags2 = 0;
+ }
+ no_of_chars = j;
+ curfnt->maxchars=no_of_chars;
+ }
+ else if (cc<0 || cc>=no_of_chars) badvf("character code out of range");
cd = curfnt->chardesc + cc;
cd->TFMwidth = scalewidth(vfquad(), scaledsize);
} else {