ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Writing Japanese using ConTeXt
@ 2003-06-08 11:48 Tim 't Hart
  2003-06-09 14:16 ` Matthew Huggett
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Tim 't Hart @ 2003-06-08 11:48 UTC (permalink / raw)


Hello all,

This is my first message to the list. I've been using ConTeXt for a few
months now, and so far it does everything I want to do with it, plus much
and much more!

Recently, I've made the 'unwise' decision to start studying Japanese next
year, and of course I want to keep on using ConTeXt to write my school
papers. I am already able to create Japanese documents using a terrific
Japanese TeX distribution (w32tex) and pLaTeX, but everyone on this
mailinglists knows that LaTeX is kinda 'weird' (to put it mildly) when you
are used to the beauty that is ConTexT! :-)  So I decided to find a way to
write Japanese in ConTeXt.

First I tried using the eOmega/ConTeXt combination since I have some great
OTPs for it, but soon found out that Omega is still "the TeX of the future",
in other words, not the "TeX of today" and extremely unstable.

Then I decided to try ConTeXt's UTF-8 support. I created the following test
file:
--------------
\chardef\utfunihashmode=1

\setupunicodefont
  [japanese]
  [scale=1.0]

\definefontsynonym [JapaneseMinchoRegular][cyberb]
\defineunicodefont [Mincho][JapaneseMincho][japanese]

\Mincho \enableregime[utf]

\starttext
...
<Imagine a bunch of UTF-8 encoded Japanese characters here>
...
\stoptext
--------------
cyberb is the Unicode font cyberbit.ttf which I installed using ttf2tfm:
ttf2tfm cyberbit.ttf cyberb@Unicode@

For output I use dvipdfmx with the following line added to the map file:
cyberb@Unicode@		Identity-H	:0:cyberbit.ttf

Well, to my big surprise, it worked! I saw the characters without a problem.
Using the 'scale' option of \setupunicodefont I could also change the size
of the characters. Great!

But since there are usually no spaces in a Japanese sentence, there is no
line breaking. And as you can imagine, line breaking is a useful feature to
have! :-)

I imagined that the line breaking problem is also happening when someone
wants to write Chinese, so I decided to take a look in ConTeXt's Chinese
module to see how it is handled there.

I saw that the Chinese module adds an interglyph space after a character,
which is breakable by TeX. This happens in a macro that is (indirectly)
called using \setupunicodefont and the 'command' option. I decided to try
the same in my test file. But first, I checked to see if using the 'command'
option in \setupunicodefont actually worked:

I added the following macro:

\def\HandleJapaneseGlyph
  {\insertunicodeglyph}

And changed my \setupunicodefont into:

\setupunicodefont
  [japanese]
  [scale=1.0,
  command=\HandleJapaneseGlyph]

Well, I still get Japanese characters like normal. I imagined that if I
removed \insertunicodeglyph from my macro, I wouldn't get to see them. But
this is not the case. I found out that I can do anything in my macro, but it
doesn't have an effect on the Japanese characters. They still get printed. I
also found out that I can even use command=\whateveryoulike and it still
wouldn't complain that such a macro doesn't exist. I get the feeling that
the command option is completely ignored. Apparently, my idea isn't going to
work. :-(

To make a long story even longer, I would like to know why it doesn't work,
or what I should do in order to make it work. What is the correct method to
divert the Unicode character output to another macro so that I can add a
breakable space after each character?

Well, I've been using ConTeXt for only a few months now, so maybe the
complexity of this is way over my head. At least it kept me busy! But on the
other hand, I don't think writing Japanese is much more different than
writing Chinese. It must be possible to achieve without much trouble or
reinventing the wheel.

Thanks for listening,
Tim

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Writing Japanese using ConTeXt
@ 2003-06-17  7:15 Lei Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Lei Wang @ 2003-06-17  7:15 UTC (permalink / raw)


I have posted the following to the list. But it seems disappeared. :-)
So again.

> One other point that may or may not matter is that ... I'm not sure if
> this is the correct terminology, but the code points of the Japanese
> character sets are arrayed in a sparse matrix (?). Each plane is
> 194x194, rather than 256x256. I used to know why.

Although the plane only have 194 characters each, many Japanese
fonts used by TeX were split by 256 per subfonts as that in Chinese 
CJK compact mode. 

----- Original Message ----- 
From: "Lei Wang" <leiwang@swt.edu>
To: <ntg-context@ntg.nl>
Sent: Wednesday, June 11, 2003 11:50 AM
Subject: Re: [NTG-context] Writing Japanese using ConTeXt


> Right. Although there are many Chinese unicode fonts, Both unix and windows 
> remap them to GBK or GB when used. As for Japanese in ConTeXt, I think
> it may be better to support the SJIS or other common used encoding, too.
> UTF8 is good, but it is inconvenience since I found few editor can save your file
> in UTF8 encoding under Windows. So I have to use convert tools to convert 
> my files.
> 
> I am not familiar with the Japanese encodings. But I think it can be implement in
> ConTeXt as Chinese because many things are in the same way. Remap them
> according their encodings (JIS, SJIS,etc.) should work if we can solve the
> one problem that Japanese SJIS encoding has some one-byte characters in the range
> 0XA1 - 0XDF while Chinese and Korean only have two-byte characters. 
> 

 Wang

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2003-06-17  7:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-08 11:48 Writing Japanese using ConTeXt Tim 't Hart
2003-06-09 14:16 ` Matthew Huggett
2003-06-09 16:33   ` Tim 't Hart
2003-06-10  8:18     ` Hans Hagen
2003-06-10 20:02       ` Tim 't Hart
2003-06-11  2:35         ` Matthew Huggett
2003-06-09 23:24 ` Matt Gushee
2003-06-10  7:41   ` Matthew Huggett
2003-06-10  8:13   ` Hans Hagen
2003-06-10 19:36     ` Tim 't Hart
2003-06-15 21:03 ` Hans Hagen
2003-06-15 22:22   ` Matt Gushee
2003-06-16  7:55     ` Hans Hagen
2003-06-16  4:37   ` Tim 't Hart
2003-06-16  7:51     ` Hans Hagen
2003-06-17  7:15 Lei Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).