summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvi2tty/dvi2tty-PATCHES/patch-03-uptex
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvi2tty/dvi2tty-PATCHES/patch-03-uptex')
-rw-r--r--Build/source/texk/dvi2tty/dvi2tty-PATCHES/patch-03-uptex646
1 files changed, 646 insertions, 0 deletions
diff --git a/Build/source/texk/dvi2tty/dvi2tty-PATCHES/patch-03-uptex b/Build/source/texk/dvi2tty/dvi2tty-PATCHES/patch-03-uptex
new file mode 100644
index 00000000000..7e50b25af42
--- /dev/null
+++ b/Build/source/texk/dvi2tty/dvi2tty-PATCHES/patch-03-uptex
@@ -0,0 +1,646 @@
+diff -ur dvi2tty-5.3.4.orig/Changelog dvi2tty-5.3.4/Changelog
+--- dvi2tty-5.3.4.orig/Changelog 2010-11-13 16:36:04.000000000 +0100
++++ dvi2tty-5.3.4/Changelog 2011-11-21 19:56:42.000000000 +0100
+@@ -1,4 +1,9 @@
+ /******************************************************************************
++ * Takuji Tanaka: 20111119 (KXD02663@nifty.ne.jp)
++ * Used ptexenc library for Japanese TeX.
++ * Enabled UTF8 output for Japanese TeX with option -Eu.
++ * Added upTeX DVI support with option -U.
++ * Added auto detected Japanese fonts in japanese-otf package.
+ * Marcel Mol: 20101113 (marcel@mesa.nl)
+ * Version 5.3.4
+ * Fix VERSION code
+diff -ur dvi2tty-5.3.4.orig/dvi2tty.1 dvi2tty-5.3.4/dvi2tty.1
+--- dvi2tty-5.3.4.orig/dvi2tty.1 2010-11-13 16:30:56.000000000 +0100
++++ dvi2tty-5.3.4/dvi2tty.1 2011-11-21 21:26:24.000000000 +0100
+@@ -129,7 +129,7 @@
+ Note this may interfere with -u. Best not to use -u and -s together.
+ .TP
+ .B \-J
+-Auto detect NTT JTeX and ASCII pTeX dvi format.
++Auto detect NTT JTeX, ASCII pTeX, and upTeX dvi format.
+ .TP
+ .B \-N
+ Display NTT JTeX dvi.
+@@ -137,6 +137,13 @@
+ .B \-A
+ Display ASCII pTeX dvi.
+ .TP
++.B \-U
++Display upTeX dvi.
++.TP
++.B \-Eenc
++Set output Japanese encoding. The enc argument 'e', 's', 'j', and 'u'
++denotes EUC-JP, Shift_JIS, ISO-2022-JP, and UTF-8, respectively.
++.TP
+ .B \-bdelim
+ Print the name of fonts when switching to it (and ending it). The delim
+ argument is used to delimit the fontname.
+diff -ur dvi2tty-5.3.4.orig/dvi2tty.c dvi2tty-5.3.4/dvi2tty.c
+--- dvi2tty-5.3.4.orig/dvi2tty.c 2010-11-13 16:33:50.000000000 +0100
++++ dvi2tty-5.3.4/dvi2tty.c 2011-11-21 22:30:24.000000000 +0100
+@@ -55,11 +55,11 @@
+
+ #define MAXLEN 100 /* size of char-arrays for strings */
+ #if defined(MSDOS) || defined(VMS) || defined(AMIGA)
+-#define OPTSET "haJwepPousltvbcAN" /* legal options */
+-#define OPTWARG "wepPovb" /* options with argument */
++#define OPTSET "haJweEpPousltvbcANU" /* legal options */
++#define OPTWARG "weEpPovb" /* options with argument */
+ #else
+-#define OPTSET "haJwepPousqlfFtvbcAN"/* legal options */
+-#define OPTWARG "wepPoFvb" /* options with argument */
++#define OPTSET "haJweEpPousqlfFtvbcANU" /* legal options */
++#define OPTWARG "weEpPoFvb" /* options with argument */
+ #endif
+
+ /*
+@@ -75,10 +75,9 @@
+ #define bdopt 7 /* bad option */
+ #define onepp 8 /* only one page list allowed */
+ #define noarg 9 /* argument expected */
+-#define confl 10 /* -N and -A conflict */
+-#define confj 11 /* -J conflicts -N or -A */
++#define confl 10 /* -J, -N, -A, and -U conflict */
+ #if defined(THINK_C)
+-#define nored 12 /* if no input file, redirect stdin */
++#define nored 11 /* if no input file, redirect stdin */
+ #endif
+
+
+@@ -166,6 +165,7 @@
+ Argc = argc;
+ Argv = argv;
+
++ set_enc_string (NULL, "default");
+ getargs(); /* read command line arguments */
+ #if defined(THINK_C)
+ if (inputfromfile) {
+@@ -380,10 +380,35 @@
+ j = strlen(optarg);
+ break;
+ #endif
+- /* case 'J' : japan = TRUE; break; */
+ case 'J' : jautodetect = TRUE; break;
+- case 'A' : asciip = TRUE; break; /* ASCII pTeX */
+- case 'N' : japan = TRUE; break; /* NTT jTeX */
++ case 'U' : uptex = TRUE; japan = TRUE; /* upTeX */
++ jautodetect = FALSE;
++ enable_UPTEX(true);
++ set_enc_string (NULL, UPTEX_INTERNAL_ENC);
++ break;
++ case 'A' : asciip = TRUE; japan = TRUE; /* ASCII pTeX */
++ jautodetect = FALSE;
++ set_enc_string (NULL, PTEX_INTERNAL_ENC);
++ break;
++ case 'N' : nttj = TRUE; japan = TRUE; /* NTT jTeX */
++ jautodetect = FALSE;
++ set_enc_string (NULL, JTEX_INTERNAL_ENC);
++ break;
++ case 'E' :
++ switch (optarg[0]) {
++ case 'e' :
++ set_enc_string ("euc", NULL); break;
++ case 's' :
++ set_enc_string ("sjis", NULL); break;
++ case 'j' :
++ set_enc_string ("jis", NULL); break;
++ case 'u' :
++ set_enc_string ("utf8", NULL); break;
++ default :
++ usage(noarg);
++ }
++ j++;
++ break;
+ case 't' : ttfont = TRUE; break;
+ case 'l' : noffd = TRUE; break;
+ case 's' : scascii ^= 1; break;
+@@ -436,14 +461,12 @@
+ }
+
+ /* Option conflict */
+- if (japan && asciip) {
++ if ((asciip && uptex) ||
++ (nttj && (asciip || uptex)) ||
++ (jautodetect && (nttj || asciip || uptex))) {
+ usage(confl);
+ }
+
+- if (jautodetect && (japan || asciip)) {
+- usage(confj);
+- }
+-
+ return;
+
+ } /* setoption */
+@@ -707,7 +730,10 @@
+ void usage(int uerr)
+ {
+
+- fprintf(stderr, "%s", Copyright);
++ if (jautodetect || nttj || asciip || uptex)
++ fprintf(stderr, "%s (%s) %s", Progname, get_enc_string(), Copyright);
++ else
++ fprintf(stderr, "%s %s", Progname, Copyright);
+
+ if (uerr != ign) {
+ fprintf(stderr,"\n%s: ", progname);
+@@ -734,9 +760,7 @@
+ break;
+ case onepp : fprintf(stderr, "only one pagelist allowed");
+ break;
+- case confl : fprintf(stderr, "-N and -A are conflicting");
+- break;
+- case confj : fprintf(stderr, "-J conflicts -N or -A");
++ case confl : fprintf(stderr, "-J, -N, -A, and -U are mutually exclusive");
+ break;
+ #if defined(THINK_C)
+ case nored : fprintf(stderr, "\nIf no input file is given in\
+@@ -794,12 +818,16 @@
+ fprintf(stderr,
+ " -u Toggle latin1 support (default %s).\n", DEFLATIN1 ? "on" : "off");
+ fprintf(stderr,
+- " -J Enable auto detect for NTT JTeX and ASCII pTeX (japanese fonts).\n");
++ " -J Enable auto detect for NTT JTeX, ASCII pTeX, and upTeX (japanese fonts).\n");
+ fprintf(stderr,
+ " -N Support NTT JTeX dvi.\n");
+ fprintf(stderr,
+ " -A Support ASCII pTeX dvi.\n");
+ fprintf(stderr,
++ " -U Support upTeX dvi.\n");
++ fprintf(stderr,
++ " -Eenc Output Japanese encoding. e:EUC s:SJIS j:JIS, u:UTF8.\n");
++ fprintf(stderr,
+ " -c Override -a -u -s and print all characters 0-255.\n");
+ fprintf(stderr,
+ " -bdelim Print font switch as text: delimcmr10miled\n");
+diff -ur dvi2tty-5.3.4.orig/dvi2tty.h dvi2tty-5.3.4/dvi2tty.h
+--- dvi2tty-5.3.4.orig/dvi2tty.h 2010-11-13 16:33:42.000000000 +0100
++++ dvi2tty-5.3.4/dvi2tty.h 2011-11-21 22:28:42.000000000 +0100
+@@ -20,7 +20,8 @@
+
+ #define VERSION "5.3.4"
+
+-#define Copyright "dvi2tty Copyright (C) 1984, 1985, 1986 Svante Lindahl.\n\
++#define Progname "dvi2tty"
++#define Copyright "Copyright (C) 1984, 1985, 1986 Svante Lindahl.\n\
+ Copyright (C) 1989-2010 M.J.E. Mol, MESA Consulting B.V."
+
+
+@@ -54,6 +55,18 @@
+ */
+ #define MAXTERMWIDTH 332
+
++#include <ptexenc/ptexenc.h>
++#include <ptexenc/unicode.h>
++
++/* internal encoding for NTT JTeX : "euc" */
++#define JTEX_INTERNAL_ENC "euc"
++
++/* internal encoding for ASCII pTeX : "euc" or "sjis" */
++#define PTEX_INTERNAL_ENC "euc"
++
++/* internal encoding for upTeX : "uptex" */
++#define UPTEX_INTERNAL_ENC "uptex"
++
+ /*
+ * ERROR CODES , don't start with 0
+ */
+@@ -109,9 +122,11 @@
+ extern bool latin1; /* latin1 chars (dvistuff.c) */
+ extern bool accent; /* Output accent stuff(dvistuff.c) */
+ extern bool ttfont; /* tt font assumed (dvistuff.c) */
+-extern bool japan; /* NTT jTeX font support (dvistuff.c) */
++extern bool jautodetect; /* Autodetect NTT jTeX, ASCII pTeX and upTeX (dvistuff.c) */
++extern bool nttj; /* NTT jTeX font support (dvistuff.c) */
+ extern bool asciip; /* ASCII pTeX font support (dvistuff.c) */
+-extern bool jautodetect; /* Autodetect NTT jTex and ASCII pTeX (dvistuff.c) */
++extern bool uptex; /* upTeX font support (dvistuff.c) */
++extern bool japan; /* japanized TeX font support (dvistuff.c) */
+ extern bool noffd; /* output ^L or formfeed (dvistuff.c) */
+ extern bool printfont; /* include font switches (dvistuff.c) */
+ extern bool allchar; /* output all characters (dvistuff.c */
+diff -ur dvi2tty-5.3.4.orig/dvi2tty.tex dvi2tty-5.3.4/dvi2tty.tex
+--- dvi2tty-5.3.4.orig/dvi2tty.tex 2010-10-30 12:13:29.000000000 +0200
++++ dvi2tty-5.3.4/dvi2tty.tex 2011-11-21 21:26:57.000000000 +0100
+@@ -192,11 +192,16 @@
+ terminals in Scandinavia are mapped to ``\{$|$\}[\bs ]''.
+ Note this may interfere with -u. Best not to use -u and -s together.
+ \item[{{\bf -J}}]
+-Auto detect NTT JTeX and ASCII pTeX dvi format.
++Auto detect NTT JTeX, ASCII pTeX, and upTeX dvi format.
+ \item[{{\bf -N}}]
+ Display NTT JTeX dvi.
+ \item[{{\bf -A}}]
+ Display ASCII pTeX dvi.
++\item[{{\bf -U}}]
++Display upTeX dvi.
++\item[{{\bf -Eenc}}]
++Set output Japanese encoding. The enc argument 'e', 's', 'j', and 'u'
++denotes EUC-JP, Shift\_JIS, ISO-2022-JP, and UTF-8, respectively.
+ \end{list}
+ %
+ % NOTE --- No other files are used under VMS.
+diff -ur dvi2tty-5.3.4.orig/dvistuff.c dvi2tty-5.3.4/dvistuff.c
+--- dvi2tty-5.3.4.orig/dvistuff.c 2011-01-27 13:20:02.000000000 +0100
++++ dvi2tty-5.3.4/dvistuff.c 2011-11-21 22:41:54.000000000 +0100
+@@ -87,13 +87,6 @@
+ #define sget3() snum(3)
+ #define sget4() snum(4)
+
+-#if !defined(JIS)
+-# define JIS 1 /* if 0 then EUC or SJIS */
+-#endif
+-#if !defined(SJIS)
+-# define SJIS 0 /* if !JIS, 0 then EUC */
+-#endif
+-
+
+ /*
+ * Structure and variable definitions
+@@ -122,7 +115,7 @@
+ long num;
+ struct _font * next;
+ char * name;
+- char flags; /* to store font types, to get rid of japan/asciip/ttfont/symbolfon/mifont vars */
++ char flags; /* to store font types, to get rid of nttj/asciip/uptex/ttfont/symbolfon/mifont vars */
+ int fontnum; /* helper for japanese fonts */
+ } font;
+
+@@ -140,8 +133,10 @@
+ bool accent; /* if true output accents etc: \'{e} etc. */
+ bool ttfont = FALSE; /* if true we assumed ttfonts, not cmr */
+ bool symbolfont = FALSE; /* true if font is a symbol font */
+-bool japan = FALSE; /* switch to NTT japanese fonts ... */
++bool nttj = FALSE; /* switch to NTT japanese fonts ... */
+ bool asciip = FALSE; /* switch to ASCII japanese fonts ... */
++bool uptex = FALSE; /* switch to upTeX CJK fonts ... */
++bool japan = FALSE; /* switch to NTT/ASCII/.. japanese fonts ... */
+ bool jautodetect = FALSE; /* switch if do auto detection of Japanese TeX */
+ bool jdetect = FALSE; /* switch if Japanese TeX detection is done */
+ bool mifont = FALSE; /* ASCII japanese font ??? */
+@@ -177,14 +172,7 @@
+ font * fonts = NULL; /* List of fontnames defined */
+ font * fnt = NULL; /* Current font */
+
+-#if JIS
+-# define SJIS 0
+-int inkanji = 0; /* is in kanji sequence */
+-# define KANJIIN "\033$B" /* was $@ in debian 5.1-13 patch.. */
+-# define KANJIOUT "\033(J"
+-#endif
+-int kanji1 = 0; /* is first kanji character */
+-int kanji2 = 0; /* is second kanji character */
++int kanji1 = 0; /* number of rest of trailer bytes in kanji character */
+
+
+
+@@ -219,7 +207,7 @@
+ void setfont (long);
+ void jischar (unsigned long);
+ int compute_jis (int, unsigned int, unsigned int *, unsigned int *);
+-void dokanji (unsigned long);
++void dokanji (long);
+ int getjsubfont (char *);
+
+ #else
+@@ -249,7 +237,7 @@
+ void setfont (long fntnum);
+ void jischar (unsigned long ch);
+ void compute_jis (int f, unsigned int c, unsigned int * ku, unsigned int * ten);
+-void dokanji (unsigned long ch);
++void dokanji (long ch);
+ int getjsubfont (char * s);
+ #if defined(VMS)
+ long vmsseek ();
+@@ -448,9 +436,9 @@
+ errorexit(illop);
+ else
+ switch (opcode) {
+- case SET1 : japan ? jischar(get1()) : setchar(get1());break;
+- case SET2 : asciip ? dokanji(get2()) : setchar(get2()); break;
+- case SET3 : setchar(get3()); break;
++ case SET1 : nttj ? jischar(get1()) : setchar(get1());break;
++ case SET2 : (asciip || uptex) ? dokanji(get2()) : setchar(get2()); break;
++ case SET3 : uptex ? dokanji(get3()) : setchar(get3()); break;
+ case SET4 : setchar(get4()); break;
+ case SET_RULE : { long height = sget4();
+ rule(MOVE, sget4(), height); break;
+@@ -617,8 +605,9 @@
+
+ void printpage(void)
+ {
+- register int i, j;
++ register int i, j, k;
+ register unsigned char ch;
++ unsigned char buff[4];
+
+ if (sptr != 0)
+ fprintf(stderr, "dvi2tty: warning - stack not empty at eop.\n");
+@@ -637,75 +626,59 @@
+ i++, j++) {
+ ch = currentline->text[i - leftmargin];
+
+- if (asciip) {
+- if (kanji1) {
+-#if !JIS && !SJIS
+- ch |= 0x80;
+-#endif
+- kanji2 = 1;
+- kanji1 = 0;
+- }
+- if (!kanji2 && ch > 127) {
+- kanji1 = 1;
+-#if JIS
+- if (!inkanji) {
+- inkanji = 1;
+- fprintf(output, KANJIIN);
+- }
+- ch &= 0x7f;
+-#endif
+- }
+-#if JIS
+- if (!kanji1 && !kanji2 && inkanji) {
+- fprintf(output, KANJIOUT);
+- inkanji = 0;
+- }
+-#endif
+- if (kanji1 && (j >= (int) foo) &&
+- (currentline->charactercount > i+1)) {
+-#if JIS
+- if (inkanji)
+- fprintf(output, KANJIOUT);
+-#endif
+- fprintf(output, "*\n"); /* if line to large */
+- fprintf(output, " *"); /* mark output */
+-#if JIS
+- if (inkanji)
+- fprintf(output, KANJIIN);
+-#endif
+- j = 2;
+- }
+- }
+-
+- if (ch >= SPACE || allchar)
+- putc(ch, output);
++ if (japan) {
++ if (ch > 127) {
++ for (k = 0; k < 4; k++) {
++ if (i - leftmargin + k < LINELEN+1)
++ buff[k] = currentline->text[i - leftmargin + k];
++ else buff[k] = '\0';
++ }
++ kanji1 = multistrlen(buff, 4, 0) - 1;
++ }
++ else kanji1 = 0;
++ if (kanji1 && (j + kanji1 > (int) foo) &&
++ (currentline->charactercount > i+1)) {
++ putc2('*', output);
++ putc2('\n', output); /* if line to large */
++ putc2(' ', output);
++ putc2('*', output); /* mark output */
++ j = 2;
++ }
++ }
++
++ if (ch >= SPACE || allchar) {
++ if (japan) {
++ for (k = 0; k < kanji1; k++) {
++ putc2(ch, output);
++ i++; j++;
++ ch = currentline->text[i - leftmargin];
++ }
++ putc2(ch, output);
++ }
++ else
++ putc(ch, output);
++ }
+ if ((j > (int) foo) && (currentline->charactercount > i+1)) {
+-#if JIS
+- if (asciip && inkanji)
+- fprintf(output,KANJIOUT);
+-#endif
+- fprintf(output, "*\n"); /* if line to large */
+- fprintf(output, " *"); /* mark output */
+-#if JIS
+- if (asciip && inkanji)
+- fprintf(output, KANJIIN);
+-#endif
+- j = 2;
+- }
+- if (asciip)
+- kanji2 = 0;
++ if (japan) {
++ putc2('*', output);
++ putc2('\n', output); /* if line to large */
++ putc2(' ', output);
++ putc2('*', output); /* mark output */
++ }
++ else {
++ fprintf(output, "*\n"); /* if line to large */
++ fprintf(output, " *"); /* mark output */
++ }
++ j = 2;
++ }
+ }
+ }
+- putc('\n', output);
++ if (japan)
++ putc2('\n', output);
++ else
++ putc('\n', output);
+ }
+
+-#if JIS
+- if (asciip && !kanji1 && !kanji2 && inkanji) {
+- fprintf(output, KANJIOUT);
+- inkanji = 0;
+- }
+-#endif
+-
+ currentline = firstline;
+ while (currentline->next != nil) {
+ currentline = currentline->next;
+@@ -988,23 +961,19 @@
+ * DOKANJI -- Process a kanji character opcode.
+ */
+
+-void dokanji(unsigned long ch)
++void dokanji(long ch)
+ {
+-#if SJIS
+- register int c1, c2;
++ long i;
+
+- c1 = (ch >> 8) & 0xff;
+- c2 = ch & 0xff;
++ i = toBUFF(fromDVI(ch));
++ kanji1 = 3;
++ if (BYTE1(i) != 0) outchar(BYTE1(i));
++ kanji1 = 2;
++ if (BYTE2(i) != 0) outchar(BYTE2(i));
+ kanji1 = 1;
+- outchar((((c1 - 1) >> 1) + ((c1 <= 0x5e) ? 0x71 : 0xb1)));
++ /* always */ outchar(BYTE3(i));
+ kanji1 = 0;
+- outchar((c2 + ((c1 & 1) ? ((c2 < 0x60) ? 0x1f : 0x20) : 0x7e)));
+-#else
+- kanji1 = 1;
+- outchar(0x80 | ( ch >> 8 ));
+- kanji1 = 0;
+- outchar(ch & 0xff);
+-#endif
++ /* always */ outchar(BYTE4(i));
+
+ return;
+
+@@ -1019,7 +988,7 @@
+ void dochar(unsigned char ch)
+ {
+
+- if (japan && fnt->fontnum)
++ if (nttj && fnt->fontnum)
+ jischar((long) ch);
+ else if (symbolfont == TRUE)
+ symchar(ch);
+@@ -1048,8 +1017,8 @@
+ case 14: ch = 'O'; break;
+ case 15: ch = 'o'; break;
+ case 24: ch = '~'; break;
+- case 32: ch = japan ? '<' : 32; break; /* really only for japan? */
+- case 33: ch = japan ? '>' : 33; break; /* really only for japan? */
++ case 32: ch = nttj ? '<' : 32; break; /* really only for japan? */
++ case 33: ch = nttj ? '>' : 33; break; /* really only for japan? */
+ case 102: ch = '{'; break;
+ case 103: ch = '}'; break;
+ case 104: ch = '<'; break;
+@@ -1284,6 +1253,14 @@
+ /*----------------- end of 'latin1 / Scandinavian code' ----------------*/
+
+ if (foo == leftmargin-1) {
++ if (japan) {
++ while (((currentline->text[j - leftmargin] != SPACE) ||
++ (kanji1 && (currentline->text[j+kanji1 - leftmargin] != SPACE)))
++ && (j < rightmargin)) {
++ j++;
++ h += charwidth;
++ }
++ } else {
+ while (j < rightmargin &&
+ ( (currentline->text[j - leftmargin] != SPACE) ||
+ (kanji1 && (currentline->text[j+1 - leftmargin] != SPACE))
+@@ -1291,6 +1268,7 @@
+ j++;
+ h += charwidth;
+ }
++ }
+ }
+ if ( allchar || ((ch >= SPACE) && (ch != DEL)) ||
+ ((latin1 || scascii) && (ch == 23)) ) {
+@@ -1321,7 +1299,7 @@
+ register long saveh;
+
+ saveh = h;
+- if (japan)
++ if (nttj)
+ dochar((unsigned char) charnr);
+ else if (allchar || ((charnr >= 0) && (charnr <= LASTCHAR)))
+ outchar((unsigned char) charnr);
+@@ -1351,6 +1329,43 @@
+ } /* setchar */
+
+
++static const char *ptex_fontchk[] = {
++ "min", "goth", "jis",
++ "hmin", "hgoth", "hmgoth", /* japanese-otf package */
++ "nmlmin", "nmlgoth", "nmlmgoth",
++ "hiramin", "hirakaku", "hiramaru",
++ NULL /* end */
++};
++
++static const char *uptex_fontchk[] = {
++ "umin", "ugoth", "ujis",
++ "upjis", "upjpn", "upsch", "uptch", "upkor",
++ "uphmin", "uphgoth", "uphmgoth", /* japanese-otf package */
++ "upnmlmin", "upnmlgoth", "upnmlmgoth",
++ "uphiramin", "uphirakaku", "uphiramaru",
++ NULL /* end */
++};
++
++static const char *jtex_fontchk[] = {
++ "dmj", "dgj",
++ NULL /* end */
++};
++
++static int checkjfont(const char **jfontlist, const char *name)
++{
++ int i, len;
++ const char *tmpfont;
++
++ i=0;
++ while ( (tmpfont=jfontlist[i]) != NULL ) {
++ len=strlen(tmpfont);
++ if ( !strncmp(tmpfont, name, len) ) return 1;
++ i++;
++ }
++ return 0;
++} /* checkjfont */
++
++
+
+ /*
+ * FONTDEF -- Process a font definition.
+@@ -1402,22 +1417,33 @@
+ */
+ fonts->flags = 0;
+
+- if (jautodetect && asciip == FALSE && japan == FALSE && !jdetect) {
+- if (!strncmp("min", name, 3) || !strncmp("got", name, 3)) {
++ if ((asciip == FALSE && nttj == FALSE && uptex == FALSE)
++ && (!jdetect) && jautodetect) {
++ if ( checkjfont(ptex_fontchk, name) ) {
+ /* Detect as ASCII TeX */
+ asciip = TRUE;
+- japan = FALSE;
+- jdetect = TRUE;
++ nttj = uptex = FALSE;
++ japan = jdetect = TRUE;
++ fonts->flags |= MIFONT;
++ set_enc_string (NULL, PTEX_INTERNAL_ENC);
++ } else if ( checkjfont(uptex_fontchk, name) ) {
++ /* Detect as upTeX */
++ uptex = TRUE;
++ nttj = asciip = FALSE;
++ japan = jdetect = TRUE;
+ fonts->flags |= MIFONT;
+- } else if (!strncmp("dmj", name, 3) || !strncmp("dgj", name, 3)) {
++ enable_UPTEX(true);
++ set_enc_string (NULL, UPTEX_INTERNAL_ENC);
++ } else if ( checkjfont(jtex_fontchk, name) ) {
+ /* Detect as NTT JTeX */
+- asciip = FALSE;
+- japan = TRUE;
+- jdetect = TRUE;
++ nttj = TRUE;
++ asciip = uptex = FALSE;
++ japan = jdetect = TRUE;
+ fonts->flags |= JAPFONT;
++ set_enc_string (NULL, JTEX_INTERNAL_ENC);
+ }
+ }
+- if (japan)
++ if (nttj)
+ fonts->fontnum = getjsubfont(name);
+ else
+ fonts->fontnum = 0;
+@@ -1511,7 +1537,9 @@
+ unsigned int Ku, Ten;
+
+ compute_jis(fnt->fontnum, (unsigned int) ch, &Ku, &Ten);
++ kanji1 = 1;
+ outchar(Ku+128);
++ kanji1 = 0;
+ outchar(Ten+128);
+
+ return;