[pdftex] Generating CJK in PDF

Otfried Cheong otfried at cs.uu.nl
Tue May 8 12:19:10 CEST 2001


 > > I got this feature to work after seeing Hans' message, but it took
 > > some reading of pdftex sources to find out about the undocumented
 > > /index<n> syntax for *.enc files...
 > 
 > I would be glad if you can send me a small but complete example for
 > testing.

Here's a very quick tour of what I did.  I wanted to make 'yoonm.ttf'
accessible from TeX using Unicode encoding (Unicode.sfd). So I run 

ttf2tfm yoonm.ttf yoonm at Unicode@

This generates yoonm00.tfm, yoonm01.tfm, ... yoonmff.tfm.  For each
subfont you also need an *.enc file, which simply maps the code points
in the subfont to glyph indices in yoonm.ttf.  E.g., yoonmac.enc looks
like this:

/YoonmacEncoding [
  /index123 /index124 /index728 /index248
  ...
] def

As you may have guessed /index<n> refers to the glyph with glyph index <n>.

Now the only missing item is the map file 'yoonm.map':

yoonm00 <yoonm.ttf <yoonm00.enc
yoonm01 <yoonm.ttf <yoonm01.enc
yoonm02 <yoonm.ttf <yoonm02.enc
...
yoonmff <yoonm.ttf <yoonmff.enc

Add yoonm.map to pdftex.cfg (or insert it into one of the existing
maps), put the .tfm and .enc files in the pdftex path, and you are
ready to use 'yoonm.ttf' using CJK.

This is really all -- no subfonts need to be generated.  Whenever the
TeX code refers to a raw TeX font yoonmXX, pdftex synthesizes an
embedded TTF font by subsetting 'yoonm.ttf' (and so there will be
quite a few disjoint subsets of the same original font in the PDF
output).

I'm really happy with this system, it makes working with TTF fonts so
much easier.  I still need to figure out the best way for adding
/ToUnicode maps -- right now I'm thinking it has to go in the .fd
files -- but then it'll be perfect.

 > > The .enc files contain the same information as the .sfd file, but
 > > using glyph indices instead of char codes.  I've just extended
 > > ttf2tfm so that together with the .tfm files it writes the .enc
 > > files.  I guess one could make it create the /ToUnicode cmap files
 > > and the .map file for pdftex as well.
 > 
 > Please send me the patch.

I can bring it from home, but it seems it's broken.  I'm sure I didn't
do the vertical variant handling right, because I didn't even notice
it was there.  Probably you can do it better starting without my
patch...

 > I fear this won't be possible.  For example, the current version from
 > ttf2tfm uses some OpenType features to get vertical glyph
 > representation forms for pseudo-vertical typesetting (i.e. rotated
 > glyphs) from a CJK font if such an OpenType table is available.  The
 > character codes are the same, but you'll get different glyph indices.

Aha, I didn't realize this.  Well, I'm happy to live with the system
as it is if I know why :-)

Otfried





More information about the pdftex mailing list