Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ghostscript 4.01 and Wadalab Kanji fonts



>>>>> "Andrew" == Andrew S Howell <andy@example.com> writes:

    Andrew> I have been trying to get the Wadalab fonts to work with
    Andrew> Ghostscript 4.01. First I tried jis encoding by defining:

    Andrew> /Wadalab-mincho-0-8 (Wadalab-mincho-0-8.gsf) ;

    Andrew> Gs cores dumps if I try the following:

This is a known bug in 4.00 and 4.01, allegedly fixed in 4.03.  It has
to do with the garbage collector.  Start gs with 'gs -dNOGC' plus any
other switches you use.

    Andrew> /Wadalab-mincho-0-8 findfont 40 scalefont setfont 100 100
    Andrew> moveto <3021> show showpage

    Andrew> Maybe GS runs out out memmory, as it load the whole
    Andrew> font. I tried to understand the stack trace below, but I
    Andrew> didn't get very far.
    ...
    Andrew> #5 0x806fff3 in gs_vmreclaim ()
    ...

That's a GC function.  I don't know what the GC problem was, but Peter
Deutsch said it's fixed.  I haven't upgraded, so I don't know.  You
can work around it by using the '-dNOGC' option.  This doesn't usually
hurt for displaying text files; it increases memory usage drastically
in "escher.ps", a recursive drawing.

    Andrew> Now, what I realy want to do is display EUC encoded files,
    Andrew> so I defined:

    Andrew> /Wadalab-mincho-0-8-EUC (Wadalab-mincho-0-8-EUC.gsf);

    Andrew> Which seem to work, but sometimes core dumps.

    Andrew> Any idea what I may be doing wrong?

I don't think you're doing anything wrong.  You could be getting bit
by the GC bug again.  It's also true that the Wadalab programs are
garbage.  In particular, I seem to recall getting a Postscript
"rangecheck" error in EUC files, which means that the EUC-to-JIS
translation was done incorrectly.  They were written by people who do
fonts, not Postscript programming.  Even the C programs aren't very
well written.

You seem to have gotten as far as I have, so I won't confuse the issue 
by publishing my Fontmap etc at this point.  I'm trying to make
something that (1) doesn't require an enormous complicated fontmap,
and (2) is installable by script with reasonable defaults and some
configurability for people with banana-flavored installations.  It's
not easy since Aladdin's kanji-related programs were written as proof
of concept, not as general-purpose tools, and I'm not a good
Postscript programmer.

However, if you use Mule, you can make any EUC-encoded PS file into a
iso-2022-jp file using "M-X M-K f *iso-2022-jp*unix", resave it, then
run the following filter on the result to strip out the kanji-in and
kanji-out sequences.  As far as I know, there should normally be no
non-printable characters in a Postscript file (it's possible to make
binary images, and if you do that, you'll have to be more careful).
So the program simply panics if the escape sequence is not recognized.
Note also the escaping of the '\' and ')' characters when in JIS mode;
there may be other characters that need to be escaped (I'm not a
professional Postscript programmer :-).  If you have problems on a
specific character, check to see what its JIS representation is as
two-byte ASCII.  If it's punctuation, you probably need to fix my
program.

This method means that you have a readable PS file (the ISO-2022-JP
version) and an automatic translation to something that works with the
Wadalab fonts (I've used the JIS mode extensively).

/*
 * stripJIS.c
 *
 * standard stream filter
 * strips JIS kanji-in and kanji-out escape sequences from a stream
 *
 * NO WARRANTY; in particular treatment of Postscript escape sequences
 * is probably buggy.
 *
 * Copyright 1996 Yaseppochi-gumi
 */

#include <stdio.h> 
#define ASCII 0
#define JIS 1

int main (int argc, char *argv[]) { /* command line args not used */

  int c1, c2;
  int state = ASCII;
  while ((c1 = getchar()) >= 0) {
    if (c1 == 0x1b) {		/* process escape sequence */
      c1 = getchar();
      if (state && c1 == '(') {  /* looks like end-JIS */
        c2 = getchar();
        if (c2 == 'B') {		/* not end-JIS */
	  state = ASCII;
	} else {
	  printf ("\nPanic: expected end-JIS sequence, got ESC ( %c\n",
                  c2);
	  exit(1);
	}
      } else if (!state && c1 == '$') {  /* looks like begin-JIS */
        c2 = getchar();
        if (c2 == 'B') {		/* begin-JIS */
	  state = JIS;
	} else {
	  printf ("\nPanic: expected begin-JIS sequence, got ESC $ %c\n",
                  c2);
	  exit(1);
	}
      } else {
	printf ("\nPanic: unrecognized escape sequence ESC %c\n", c1);
	exit(1);
      }
    } else {			/* spit out text */
      if ((c1 == '\\' || c1 == ')') && state) putchar('\\');
                                /* escape backslashes and parens in JIS */
      putchar(c1);
    }
  }
  exit(0);
}

-- 
                           Stephen John Turnbull
University of Tsukuba                                        Yaseppochi-Gumi
Institute of Policy and Planning Sciences  http://turnbull.sk.tsukuba.ac.jp/
Tennodai 1-1-1, Tsukuba, 305 JAPAN                 turnbull@example.com
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links