ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Tim 't Hart" <tim@t-hart.com>
Subject: Writing Japanese using ConTeXt
Date: Sun, 8 Jun 2003 13:48:58 +0200	[thread overview]
Message-ID: <000001c32db3$f5e81750$0a01a8c0@TIMBO> (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

             reply	other threads:[~2003-06-08 11:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-08 11:48 Tim 't Hart [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001c32db3$f5e81750$0a01a8c0@TIMBO' \
    --to=tim@t-hart.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).