This file describes how to set up the CJK package with Wadalab postscript
fonts for Japanese under Unix-like operating systems using distributions
based on web2c (teTeX, TeXLive, etc.).

The printer does not need to have resident Japanese fonts.


By Hin-Tak Leung <htl10@users.sourceforge.net>, September 1997.

Revised November 1998.

Last revised by Werner Lemberg, July 2006.

===================


Summary steps
-------------

  1. Download the CJK package and install it.

  2. Download and install the Wadalab font bundles for the CJK package from
     CTAN.

 3a. Update `<TEXMF>/dvips/psfont.map', or update your `~/.dvipsrc' file.
     Use the updmap script if possible.

 3b. Alternatively, create a `config.wadalab' file.

 3c. For pdfTeX, update `pdftex.map' (normally handled already by the updmap
     script).  Omit this step for recent teTeX and TeXLive versions.

 3d. For dvipdfmx (and dvipdfm), update `dvipdfm.map' (normally handled
     already by the updmap script).  Omit this step for recent teTeX and
     TeXLive versions.

  4. Run mktexlsr.

  5. Test it!


Details of each step
--------------------

1. The following files are essential and must be in your $TEXINPUTS path.

     CJK/texinput/:
       CJK.enc         CJK.sty         CJKnumb.sty
       CJKulem.sty     ruby.sty        standard.bdg
       standard.chr    standard.enc

     CJK/texinput/JIS/:
       JIS.cap         JIS.cpx         JISdnp.enc
       c42song.fd      EUC-JP.bdg      EUC-JP.chr
       EUC-JP.enc

     CJK/texinput/UTF8/:
       UTF8.bdg        UTF8.chr        UTF8.enc
       c70song.fd

   [Even if you don't use `c42song.fd' and `c70song.fd' these two files
    should be here to avoid a strange LaTeX error message if a font shape is
    missing.]

   [The EUC-JP files support real EUC-JP with single shift to access
    JIS X 0212.]

   And one or more of the following files:

       file name               Description
     ------------------------------------------------------------------------
       c42goth.fd  Gothic  JIS X 0208 (level 1,2 kanji), DNP font encoding
       c42maru.fd  Maru
       c42min.fd   Mincho

       c52maru.fd  Maru    JIS X 0212 (level 3 kanji), DNP font encoding
       c52min.fd   Mincho

       c70goth.fd  Gothic  JIS X 0208, Unicode font encoding

       c70maru.fd  Maru    JIS X 0208 + 0212, Unicode font encoding
       c70min.fd   Mincho

   And finally, `wadalab.map'.

   Also keep `CJK/examples/JIS.tex' for testing. The rest of the CJK files
   are not essential for this setup. Usage is documented in
   `CJK/examples/JIS.tex' but reading `CJK/doc/CJK.txt' and
   `CJK/doc/ruby.txt' is recommended.

   For pseudo vertical typesetting you need the `*.fdx' files accompaning
   the above `*.fd' files, together with the `CJKvert.sty' file.

   For using Unicode as the input encoding you should use `CJKutf8.sty'.

2. The CJK sub font packages of the Wadalab fonts can be found on CTAN in
   the directory `fonts/wadalab'. The real TeX font names consist of the
   concatenation of the family name with the subfont suffix. Examples:
   `dgjkeisen', `mrjkj', `umcj5d'.

       file name               TeX font family
                               DNP     Unicode
     ---------------------------------------------
       gothic-0-13.tar.gz      dgj     udgj
       maru-0-8.tar.gz         mrj     umrj
       maru-1-8.tar.gz         mr2j
       mincho-0-12.tar.gz      dmj     udmj  [*]
       mincho-0-8.tar.gz       mcj     umcj
       mincho-1-8.tar.gz       mc2j

       [*] The `udmj' family uses mc2j for glyphs Level 3 Kanji.  It doesn't
           really fit (mc2j is too thin), but it is still better than having
           no Level 3 Kanji at all.

   Installation should be straightforward since the directories in the
   font bundles already follow the TDS standard.

3a. Append `wadalab.map' to `<TEXMF>/dvips/config/psfont.map; or, for
   non-root users, create a `~/.dvipsrc' file containing this single line:

=========================================================================
p +/my-home/where_I_want_it/wadalab.map
=========================================================================

   (or add this line to your `~/.dvipsrc' if it already exists) and set
   $DVIPSFONTS to the location of the `*.pfb' files.

   teTeX and TeXLive users should do the following instead of the above:

     a) Copy `wadalab.map' into the `<TEXMF>/fonts/map/dvips/wadalab'
        directory. If you are non-root, create a private TEXMF tree in your
        home directory, and copy the file to a similar location in your
        private tree.

        Users of older versions of teTeX and TeXLive should use the
        directory `<TEXMF>/dvips/config' instead.

     b) Add the following line to <TEXMF>/web2c/updmap.cfg:

=========================================================================
Map wadalab.map
=========================================================================

        and call the updmap script to regenerate all program specific map
        files. If you are non-root, copy `updmap.cfg' from the main TEXMF
        tree to a similar location in your private tree and modify it there.

        Users of older version of teTeX and TeXLive should add `wadalab.map'
        to the `extra_modules' variable directly in the updmap script.

3b. Another solution is to just copy wadalab.map to the location in
   step 3a. After creating a file `config.wadalab', containing a single line

=========================================================================
p +wadalab.map
=========================================================================

   you can use the `-P wadalab' switch while calling dvips.

   The preferred location of `config.wadalab' is `<TEXMF>/dvips/wadalab' for
   recent teTeX and TeXLive versions, and `<TEXMF>/dvips/config' otherwise.

3c. [This step is optional and should be omitted for recent teTeX and
     TeXLive versions.]

   Append `wadalab.map' to `<TEXMF>/dvips/config/pdftex.map' so that pdfTeX
   can use the Wadalab fonts. The updmap script does this automatically.

3d. [This step is optional and should be omitted for recent teTeX and
     TeXLive versions.]

   Append `wadalab.map' to <TEXMF>/dvipdfm/config/dvipdfm.map so that
   dvipdfmx (and dvipdfm) can use the Wadalab fonts. The updmap script does
   this automatically.


4. Run mktexlsr to make your TeX system actually find your font data files.


5. Edit CJK/examples/JIS.tex and replace `\begin{CJK*}{JIS}{song}' by
   `\begin{CJK*}[dnp]{JIS}{xxx}'; `xxx' can be `min' (for mincho), `goth'
   (for gothic), or `maru'. To see the mincho-0-8 font (which is in `light'
   series), insert

     \fontseries{l}
     \selectfont

   in the CJK environment. All fonts use the poor-man's bold mechanism of
   the CJK package.

   Then do the sequence

     latex JIS.tex
     dvips JIS.dvi -j -o JIS.ps

   or

     dvips JIS.dvi -j -P wadalab -o JIS.ps

   if you haven't modified `psfonts.map'.  The `-j' switch activates partial
   font downloading (which usually is the default).

   At this stage running ghostview on `JIS.ps' should display it on screen.
   Send `JIS.ps' to a postscript printer or run ghostscript for
   non-postscript printers as you wish; and there you have your first
   printed Japanese document. Enjoy!

   Note: The level 3 Kanji fonts are generated in a DNP-like encoding also. 
         A single level 3 Kanji character can be most easily input with

           \CJKchar[JIS2]{<first-byte>}{<second-byte>}    ,

         provided that you have said

           \CJKfontenc{JIS2}{dnp}
           \CJKencfamily{JIS2}{xxx}

         in the preamble of your document to activate dnp font encoding for
         the JIS2 encoding in font shape `xxx' (which can be either `maru'
         or `min').

         In case you use Emacs or Mule together with cjk-enc.el (of the CJK
         package), JIS X 0212 characters can be displayed directly; they
         will be automatically converted into appropriate CJK macros.


How the Wadalab fonts have been created
---------------------------------------

This section contains a description of the conversion process which
transforms the raw Wadalab PS files into subfonts usable by the CJK package.

1. The Wadalab PS files are available from the original host

     ftp://ftp.ipl.t.u-tokyo.ac.jp/Font/

   Alternative locations are CTAN hosts like ftp.dante.de or ftp.tug.org and
   its mirrors:

     ftp://ftp.dante.de/pub/tex/support/ghostscript/3rdparty
           /fonts/kanji/Font

   Obtain the following files (if you download the files from CTAN, the
   final extension is `.gz' instead of `.Z'):

     wadalab-sym.7.tar.Z          (symbols + Greek letters, necessary)

     wadalab-mincho-0-12.8.tar.Z  (JIS X 0208 level 1,2 kanji)
     wadalab-gothic-0-13.5.tar.Z
     wadalab-mincho-0-8.4.tar.Z
     wadalab-maru-0-8.4.tar.Z

     wadalab-maru-1-8.tar.Z       (JIS X 0212 level 3 kanji)
     wadalab-mincho-1-8.tar.Z

     tools/wftodm.c               (conversion program, c.f. step 2)

   Unpack the font archives in a temporary directory; you should get
   subdirectories called `wadalab-sym', `wadalab-mincho-0-12', etc.

   Note: DO NOT read the misleading `readme.ghostscript' document which
         accompanies the fonts.


2. Patch `wftodm.c' with the following to enable partial font downloading. 
   You can simply say

        patch < DNP.txt

   to do that.

=========================================================================
--- wftodm-orig2.c      Tue Sep 23 22:45:32 1997
+++ wftodm.c    Sun Jul 30 08:56:43 2006
@@ -1,6 +1,8 @@
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include <sys/types.h>
-#include <sys/time.h>
+#include <time.h>
 char *charstrs[34][256];
 int charlens[34][256];
 char *version_str="001.001";
@@ -157,6 +159,7 @@
       output_afm(i);
     }
   }
+return 0;
 }
 output_afm(file)
 {
@@ -209,14 +212,13 @@
   fprintf(ofp,"/UnderlineThickness 0 def\n");
   fprintf(ofp,"end readonly def\n");
   fprintf(ofp,"/FontName /%s def\n",fontname);
-  fprintf(ofp,"/DmEncoding [\n");
+  fprintf(ofp,"/Encoding 256 array\n");
+  fprintf(ofp,"0 1 255 {1 index exch /.notdef put} for\n");
   for(i=0;i<16;i++){
     for(j=0;j<16;j++)
-      fprintf(ofp," /c%02X",i*16+j);
-    putc('\n',ofp);
+      fprintf(ofp,"dup %d /c%02X put\n",i*16+j,i*16+j);
   }
-  fprintf(ofp,"] readonly def\n");
-  fprintf(ofp,"/Encoding DmEncoding def\n");
+  fprintf(ofp,"readonly def\n");
   fprintf(ofp,"/PaintType 0 def\n");
   fprintf(ofp,"/FontType 1 def\n");
   fprintf(ofp,"/FontMatrix [.001 0 0 .001 0 -0.16] readonly def\n");
=========================================================================

   After compilation with

     cc -O -o wftodm wftodm.c

   use it as follows:

     wftodm -FontBase dg wadalab-sym/jis*.ps wadalab-gothic-0-13/goth-*.ps
     wftodm -FontBase dm wadalab-sym/jis*.ps wadalab-mincho-0-12/min-*.ps
     wftodm -FontBase mc wadalab-sym/jis*.ps wadalab-mincho-0-8/min-*.ps
     wftodm -FontBase mr wadalab-sym/jis*.ps wadalab-maru-0-8/maru-*.ps
     wftodm -FontBase mc2 wadalab-mincho-1-8/min*.ps
     wftodm -FontBase mr2 wadalab-maru-1-8/maru*.ps

   [Note: The order of the PS files on the command line doesn't matter.]

   You should then get a whole set of {dg,dm,mc,mr}j[*].{afm,pfa} files in
   your current directory, with [*]={greek,keisen,roma,russian,sy} coming
   from sym-dir, and [*]={hira,kata,ka-kz} from the Kanji fonts.
   {mc2,mr2}j[*].{afm,pfa} with [*]={ka-kw} are JIS X 0212 level 3 Kanji
   font files.

   Note: `wftodm.c' has been updated in Oct 97; previous versions will fail.


3. Run the `makefont' script. It first normalizes the font matrix (to make
   the subfonts work with pdfTeX), then it calls afm2tfm on each of the afm
   files, and run t1disasm/t1asm (which are part of the t1utils package) on
   each of the PFA files to convert them to PFB files which are much
   smaller.


4. Run the `fixwada2.pl' script to correct the glyph names. This needs the
   perl program and the files `DNP.sfd' (from the CJK package),
   `JIS0208.TXT', and `JIS0212.TXT' (from ftp.unicode.org, in the `OBSOLETE'
   directory).

     perl fixwada2.pl dgj jis0208
     perl fixwada2.pl mrj jis0208
     perl fixwada2.pl mr2j jis0212
     perl fixwada2.pl dmj jis0208
     perl fixwada2.pl mcj jis0208
     perl fixwada2.pl mc2j jis0212


5. Run the `makeuniwada.pl' script -- it needs the same auxiliary files
   as `fixwada2.pl' -- to create virtual fonts for Unicode input encoding.

     perl makeuniwada.pl dgj udgj
     perl makeuniwada.pl mrj mr2j umrj
     perl makeuniwada.pl dmj mc2j udmj
     perl makeuniwada.pl mcj mc2j umcj


Thanks
------

 Werner Lemberg <wl@gnu.org> for creating CJK and comments to this help
 document.

and

 Joshua Redstone <redstone@cs.washington.edu> for contribution to non-root
 setups.

Also check out the following variables: $TEXFORMATS, $TEXINPUTS, $TEXFONTS,
$DVIPSFONTS.


Please send any suggestions or comments to LEUNG Hin-Tak <htl10@cam.ac.uk>.

--- end of DNP.txt ---
