OS/2 eZine - http://www.os2ezine.com
Spacer
June 16, 2004

Injoy Firewall


Adding DBCS (CJK) fonts to OpenOffice

Last time we took a look at making your own National Language (NLS) version of OpenOffice for OS/2, using Chinese as an example. This time, we take a look at a related problem, that of getting DBCS (Double-Byte Character System) fonts to work with OpenOffice. (Note that Unicode does not necessarily imply DBCS. UTF-8 is the single-byte standard. UTF-16 would be the double-byte standard). DBCS is typically used for those languages for which 256 is insufficient to represent the total number of possible characters in the "alphabet". The most common ones are Chinese, Japanese and Korean or CJK as you may commonly see it being referred to as.

New applications should be developed with DBCS in mind, and OS/2 has plenty of API's to support multi-byte characters and Unicode. [Editor: In fact, apparently in Windows NT onwards, DBCS Unicode is the base character system. Using non-Unicode API's will actually cause a performance hit, according to MS, because these are wrappers around the Unicode functions. I don't know if OS/2 is the same].

What's the problem?

The biggest problem for displaying and writing CJK (DBCS) characters in OpenOffice is that we can not use the free fonts that come with OS/2-eComStation, like IBMFang, IBMSong, IBMKai, IBMHei, MOEKAI, MEOSONG and so on. They always show ugly and broken characters or even nothing! We also can not use Windows Unicode TrueType fonts (with CJK characters) in most cases. (Note that we are referring to OpenOffice for OS/2 specifically, not OS/2 in general).

As far as I know, in my experience only SimSun, Arial Unicode MS, Bitstream Cyberbit and Ming(for ISO 10646) or maybe Times New Roman WT and Monotype Sans Duospace WT can be used with OpenOffice for OS/2. But these are sometimes insufficient for office document applications (imagine being limited to just 6 or 7 fonts for your system!). Now I've found a way to work around this problem.

The Font Tool

The only free tool so far I know is FontForge. Unfortunately there is no OS/2 version of this application. I hope it will soon be ported to XFree86/OS2. In order to fix the CJK Unicode TrueType Fonts we have, we have three choices. One is go to Linux-Box and another one is shift to Winodws (I don't suggest you to use VPC/2, because it will be very sloooow), there is also a Mac build.

To get FontForge (aka PfaEdit) go to the the web site at SourceForge and download it. It's free.

  1. For Linux - (http://fontforge.sourceforge.net/index.html#binary) You can select a .RPM package or the other package. If you have Linux machine, this is most easy way to use FontForge.
  2. For Windows - You need install Cygwin first, please see below. [Editor: Cygwin is very, very big and takes a long time to install, even with 10Mb/s Ethernet!]
  3. For Mac OS.

Installation (for Windows)

It's too bad we have to hop out of OS/2 to do this. If anyone compiles it for OS/2 (even if only for XFree86/2 or HOB X11), please let us know! [Editor: On the other hand, the fonts only have to be done once, by anyone, and then possibly shared].

Edit Windows Unicode TrueType (CJK) Fonts

  1. Select File-> Open. Loading a font (before this you should use Windows file manager and copy the font file to a directory of Cygwin)
  2. Select Element --> Font Information --> Names
  3. Next we choose Encoding level. Change the Encoding to ISO-10646-1 (Unicode, BMP). Please don't try to set it to your CJK-Code, otherwise the InnoTek ft2lib will not recognize this encoding.
  4. Select TTF Names --> American English en_US

  5. File --> Generate Fonts....
    Select True Type --> Save and you will create a new font. Now copy the new font to OS/2 box and install it to the system as you would normally with any other font on OS/2. When you finish this, you should reboot the system. InnoTek's Font engine needs a reboot to let the font take effect.

    *Note: These fonts can not be used in any non-Unicode environment.

    And once you've re-booted, that's it. You should be able to see it in OpenOffice.
    (Click to enlarge)

    Troubleshooting?

    [Editor: I hope I'm translating the intent here properly] If you have problem in displaying some CJK fonts in OpenOffice, for example, if the document specifies a font your don't have, you can try to follow these steps:
    1. Copy the fontname that isn't working, i.e. you don't have it in your system.

      Mark the fontname in font field with CTRL+C keys.
    2. Open Tools menu and choose Options. Next to the OpenOffice.org dialog --> Fonts. Use Ctrl+V to paste the font to Font field. Then select a CJK font to use to replace the "missing" font. After this setting you sould see the correct CJK font now.

      (Click for larger version)

      References:

      FontForge project
      Cygwin


      Alex Lee currently ives in Germany and works as a missionary among Chinese students. He preachs Gospel to them and hope all of them become Christian.

      This article is courtesy of www.os2ezine.com. You can view it online at http://www.os2ezine.com/20040616/page_5.html.

      Copyright (C) 2004. All Rights Reserved.