diff options
Diffstat (limited to 'Build/source/texk')
-rw-r--r-- | Build/source/texk/dvipsk/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/dopage.c | 55 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/dvips.h | 6 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/pprescan.c | 46 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/scanpage.c | 49 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/virtualfont.c | 25 |
6 files changed, 149 insertions, 37 deletions
diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index afa2dfd9959..3d1e8c2e855 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,8 @@ +2020-04-19 TANAKA Takuji <ttk@t-lab.opal.ne.jp> + + * {virtualfont,pprescan,scanpage,dopage}.c, dvips.h: + Fallback multibyte character in virtual font for (u)pTeX. + 2020-04-10 Akira Kakuto <kakuto@w32tex.org> * dospecial.c: Support \special{psfile=non-ascii-name}. diff --git a/Build/source/texk/dvipsk/dopage.c b/Build/source/texk/dvipsk/dopage.c index 991ca72a859..237ea106eb7 100644 --- a/Build/source/texk/dvipsk/dopage.c +++ b/Build/source/texk/dvipsk/dopage.c @@ -129,7 +129,57 @@ dochar: NEED_NEW_BOX = 0; } #endif - cd = &(curfnt->chardesc[mychar]); + if (mychar<curfnt->maxchars) + cd = &(curfnt->chardesc[mychar]); + if (!noptex && mychar<0x1000000 && curfnt->loaded == 2 && curfnt->kind == VF_PTEX) { + if (mychar>=curfnt->maxchars || !(cd->flags & EXISTS)) { + /* try fallback */ +#ifdef DEBUG + if (dd(D_FONTS)) + fprintf(stderr, + "Fallback pTeX vf:%s char=%d(0x%06x) to %s\n", + curfnt->name, mychar, mychar, curfnt->localfonts->desc->name); +#endif /* DEBUG */ + cd = curfnt->localfonts->desc->chardesc; + if (charmove) { + 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->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->ff = ffont; + frp->curf = curfnt; + if (++frp == &frames[MAXFRAME] ) + error("! virtual recursion stack overflow"); + ffont = curfnt->localfonts; + if (ffont) { + curfnt = ffont->desc; + thinspace = curfnt->thinspace; + } else { + curfnt = NULL; + thinspace = vertsmallspace; + } + drawchar(cd, mychar); + goto end_of_vf; + } + } if (cd->flags & EXISTS) { if (curfnt->loaded == 2) { /* virtual character being typeset */ if (charmove) { @@ -256,6 +306,7 @@ case 140: /* eop or end of virtual character */ #endif break; } +end_of_vf: --frp; curfnt = frp->curf; thinspace = (curfnt) ? curfnt->thinspace : vertsmallspace; @@ -419,7 +470,7 @@ verticalmotion: /* printf("Doing vertical motion: p = %i, v = %i, vv = %i\n",p,v,vv); */ /* printf("inHTMLregion %i\n", inHTMLregion); */ if (HPS_FLAG && inHTMLregion) NEED_NEW_BOX = 1 /* vertical_in_hps() */; -#endif +#endif goto beginloop; /* * Horizontal motion is analogous. We know the exact width of each diff --git a/Build/source/texk/dvipsk/dvips.h b/Build/source/texk/dvipsk/dvips.h index a69cccb2217..a0a47797a7e 100644 --- a/Build/source/texk/dvipsk/dvips.h +++ b/Build/source/texk/dvipsk/dvips.h @@ -188,9 +188,13 @@ typedef struct tfd { struct tfd *nextsize; char *scalename; chardesctype *chardesc; - int iswide; + int iswide, kind; } fontdesctype; +#define VF_TEX (1) +#define VF_OMEGA (2) +#define VF_PTEX (3) + /* A fontmap associates a fontdesc with a font number. */ typedef struct tft { diff --git a/Build/source/texk/dvipsk/pprescan.c b/Build/source/texk/dvipsk/pprescan.c index d1a024a50b8..665e40c7998 100644 --- a/Build/source/texk/dvipsk/pprescan.c +++ b/Build/source/texk/dvipsk/pprescan.c @@ -113,11 +113,16 @@ dochar: if (curfnt==NULL) error("! Bad DVI file: no font selected"); if (mychar>=curfnt->maxchars) { - sprintf(errbuf,"! invalid char %d from font %.500s", - mychar, curfnt->name); - error(errbuf); + if (!noptex && mychar<0x1000000 && curfnt->loaded == 2 && curfnt->kind == VF_PTEX) { + /* fallback */ + } else { + sprintf(errbuf,"! [pscanpage] invalid char %d from font %.500s", + mychar, curfnt->name); + error(errbuf); + } } if (curfnt->loaded == 2) { /* scanning a virtual font character */ + struct tft *ffont0; frp->curp = curpos; frp->curl = curlim; frp->ff = ffont; @@ -125,17 +130,32 @@ dochar: if (++frp == &frames[MAXFRAME] ) error("! virtual recursion stack overflow"); cd = curfnt->chardesc + mychar; - 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"); + if (mychar>=curfnt->maxchars || cd->packptr == NULL) { + if (!noptex && mychar<0x1000000 && curfnt->kind == VF_PTEX) { /* fallback */ +#ifdef DEBUG + if (dd(D_FONTS)) + fprintf(stderr, + "We will fallback pTeX vf:%s to %s\n", + curfnt->name, curfnt->localfonts->desc->name); +#endif /* DEBUG */ + } else { + fprintf(stderr, "Wrong char code: %04X\n", mychar); + error("! a non-existent virtual character is being used; check vf/tfm files"); + } + ffont0 = curfnt->localfonts; + if (ffont0==NULL) + curfnt = NULL; + else + ppreselectfont(ffont0->desc); + } else { + curpos = cd->packptr + 2; + curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); + ffont = curfnt->localfonts; + if (ffont==NULL) + curfnt = NULL; + else + ppreselectfont(ffont->desc); } - curpos = cd->packptr + 2; - curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); - ffont = curfnt->localfonts; - if (ffont==NULL) - curfnt = NULL; - else - ppreselectfont(ffont->desc); } else if (curfnt->loaded == 3) curfnt->chardesc[mychar].flags = EXISTS; break; diff --git a/Build/source/texk/dvipsk/scanpage.c b/Build/source/texk/dvipsk/scanpage.c index ccb5142ee52..30cf7a68598 100644 --- a/Build/source/texk/dvipsk/scanpage.c +++ b/Build/source/texk/dvipsk/scanpage.c @@ -193,11 +193,16 @@ dochar: if (curfnt==NULL) error("! Bad DVI file: no font selected"); if (mychar>=curfnt->maxchars) { - sprintf(errbuf,"! invalid char %d from font %.500s", - mychar, curfnt->name); - error(errbuf); + if (!noptex && mychar<0x1000000 && curfnt->loaded == 2 && curfnt->kind == VF_PTEX) { + /* fallback */ + } else { + sprintf(errbuf,"! [scanpage] invalid char %d from font %.500s", + mychar, curfnt->name); + error(errbuf); + } } if (curfnt->loaded == 2) { /* scanning a virtual font character */ + struct tft *ffont0; frp->curp = curpos; frp->curl = curlim; frp->ff = ffont; @@ -205,23 +210,38 @@ dochar: if (++frp == &frames[MAXFRAME] ) error("! virtual recursion stack overflow"); cd = curfnt->chardesc + mychar; - 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"); + if (mychar>=curfnt->maxchars || cd->packptr == NULL) { + if (!noptex && mychar<0x1000000 && curfnt->kind == VF_PTEX) { /* fallback */ +#ifdef DEBUG + if (dd(D_FONTS)) + fprintf(stderr, + "We will fallback pTeX vf:%s to %s\n", + curfnt->name, curfnt->localfonts->desc->name); +#endif /* DEBUG */ + } else { + fprintf(stderr, "Wrong char code: %04X\n", mychar); + error("! a non-existent virtual character is being used; check vf/tfm files"); + } + ffont0 = curfnt->localfonts; + if (ffont0==NULL) + curfnt = NULL; + else if (!preselectfont(ffont0->desc)) + goto outofmem; + } else { + curpos = cd->packptr + 2; + curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); + ffont = curfnt->localfonts; + if (ffont==NULL) + curfnt = NULL; + else if (!preselectfont(ffont->desc)) + goto outofmem; } - curpos = cd->packptr + 2; - curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); - ffont = curfnt->localfonts; - if (ffont==NULL) - curfnt = NULL; - else if (!preselectfont(ffont->desc)) - goto outofmem; } else { pagecost++; if (!prescanchar(curfnt->chardesc + mychar)) goto outofmem; } - break; + 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: @@ -280,6 +300,7 @@ endofpage: */ return(2); outofmem: + printf("###sp:DBG000 %p\n", ffont); if (frp != frames) { curpos = frames->curp; curlim = frames->curl; diff --git a/Build/source/texk/dvipsk/virtualfont.c b/Build/source/texk/dvipsk/virtualfont.c index f412a4db956..6afc4683670 100644 --- a/Build/source/texk/dvipsk/virtualfont.c +++ b/Build/source/texk/dvipsk/virtualfont.c @@ -87,14 +87,14 @@ vfopen(register fontdesctype *fd) #else if (0 != (vffile=search(d, name, READBIN))) #endif - return(1); + return(VF_TEX); if (!noomega) #ifdef KPATHSEA if (0 != (vffile=search(ovfpath, n, READBIN))) #else if (0 != (vffile=search(d, n, READBIN))) #endif - return(2); + return(VF_OMEGA); return(0); } @@ -159,8 +159,9 @@ virtualfont(register fontdesctype *curfnt) integer maxcc=255; register quarterword *tempr; fontmaptype *fm, *newf; - int kindfont; - kindfont = vfopen(curfnt); /* 1 for TeX and pTeX, 2 for Omega */ + int id, kindfont; + kindfont = vfopen(curfnt); /* VF_TEX for TeX and pTeX, VF_OMEGA for Omega */ + curfnt->kind = kindfont; if (!kindfont) return (0); #ifdef DEBUG @@ -172,7 +173,7 @@ virtualfont(register fontdesctype *curfnt) /* * We clear out some pointers: */ - if (kindfont==2) { + if (kindfont==VF_OMEGA) { no_of_chars = VF_MEM_UNIT; curfnt->maxchars=VF_MEM_UNIT; free(curfnt->chardesc); @@ -196,7 +197,7 @@ 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) { - int id = 0; + id = 0; if (!noptex) { tfmopen(curfnt); /* We check if parent is jfm or not. */ id = tfm16(); @@ -218,7 +219,17 @@ virtualfont(register fontdesctype *curfnt) newf = vfontdef(scaledsize, cmd-242); if (fm) fm->next = newf; - else curfnt->localfonts = newf; + else { + curfnt->localfonts = newf; + id = 0; + if (!noptex) { + tfmopen(curfnt->localfonts->desc); /* We check if parent is jfm or not. */ + id = tfm16(); + fclose(tfmfile); + if (id == 9 || id == 11) + curfnt->kind = VF_PTEX; + } + } fm = newf; fm->next = NULL; /* FIFO */ } |