OS/2 eZine - http://www.os2ezine.com
Spacer
June 16, 2004
 
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.
If you have a comment about the content of this article, please feel free to vent in the OS/2 e-Zine discussion forums.

There is also a Printer Friendly version of this page.



Spacer
Previous Article
Home
Next Article


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)

  • Download the Cgywin "setup.exe" installer from http://www.cygwin.com .
  • Run setup.exe, it will ask you what components would you like to install. You should choose Unix way.
  • You will need the base components and the X window system (NOTE: These are separate packages, so you should need basic, shell, compression, system, lib, X11 etc.). Because the whole Cgywin package is very large, I suggest you to save it to your hard drive (maybe needs ca. 300 MB). In this way you can re-download what you still need or you want to add new part of the package.
  • Once you have Cygwin installed, start it. This should give you a terminal window running bash (a unix shell). Then you should type the command:
    $ mkdir -p /usr/local/share/fontforge /usr/local/bin /usr/local/share/man/man1
    $ cd /usr/local/bin
    $ gunzip fontforge_cygwin*.tgz
    $ tar xfv fontforge_cygwin*.tar
    $ cd /usr/local/bin/fontforge
    $ mv *.ui /usr/local/share/fontforge
    $ mv fontforge.1 /usr/local/share/man/man1
    
    This will:
    • create 3 directories
    • switch directory
    • extract .tgz to .tar
    • switch to fontforge directory
    • move .ui files
    • move .1 file
    [Editor: Now why was it I'm still on OS/2 despite having to have used UNIX for the past 12 years? :-)].
  • Now you should edit ~/.bashrc file with whatever editor you like to use:
    $ cat >> ~/.bashrc
    PATH=${PATH}:/usr/local/bin ; export PATH
    MANPATH=${MANPATH:-}:/usr/local/share/man ; export MANPATH
    ^D (<-- Ctrl + D)
    
  • Every time you want to start FontForge, you should type:
    $ xinit
    
  • This should bring up X in a large window that covers the screen and within that should be a subwindow, an xterm, running bash.
  • From the xterm you should be able start FontForge.
    $ fontforge -new
    
  • Online help of the usage: http://fontforge.sourceforge.net/overview.html

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
    • (a) Now you should rename the CJK fontname to English name. For Fontname, Family Name and Name For Humans could be the same name.
    • (b) Name For Humans is for system to show the fontname that we can understand it. In order to let CJK OS/2 system to read and use the font, we should change the name to English.

  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

    • a. Change its contents.
      Ex.: Style?Family Name, Fontname ID, Name For Humans, Copy Right, Version, License...[Editor: As a responsible publication, we have to say to you, read the notice first, make sure you're allowed to do this.]
    • b. Delete all contents of the CJK font (for Traditional Chinese (Taiwan), you should delete all the message in it)!
  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

Previous Article
Home
Next Article

Copyright (C) 2004. All Rights Reserved.