diff --git a/Documentation/Gui/LanguageSetup.gsdoc b/Documentation/Gui/LanguageSetup.gsdoc index 51350b4a9..301918367 100644 --- a/Documentation/Gui/LanguageSetup.gsdoc +++ b/Documentation/Gui/LanguageSetup.gsdoc @@ -6,153 +6,203 @@ + + $Revision$ $Date$ Using Traditional Chinese and Other Languages -

This is an introduction to using Traditional Chinese and - other languages in GNUstep. Note, however, that I have only tested - these instructions with Traditional Chinese of either BIG5 or - Unicode (iso10646-1) encoding. But since GNUstep is generally - internationalized, this introduction could be applied to other - languages with limited modification.

+

This brief article illustrates how to set up your GNUstep for + the East Asian languages known as CJK (Chinese, Japanese, and + Korean) in literature. We assume that you already know how to + set up your X Window System for your language environment such + as locale, fonts, and input methods. We also assume that you + selected 'art' as the backend of GNUstep's GUI. +

+ +

Like other computer software made outside the region, GNUstep + requires some adjustment to use those languages. The adjustment + consists of the following steps: +

+ + + Prepare one or more true type font files which contain characters + of your native language, and organize them in a certain way so that + the art backend can use them. + + + Set the environmental variable GNUSTEP_STRING_ENCODING to an + appropriate value for the language in use. + + + Set the NSGlobalDomain variables such as NSFont, NSFontSize, + and NSUserFont, to name a few, to appropriate values using the + GNUstep's utility 'defaults'. + + + +

Now we explain each step in detail.

+ +
+ Fonts + +

The art backend expects font files to be found in the + specified directories, such as + $GNUSTEP_USER_ROOT/Library/Fonts and + $GNUSTEP_SYSTEM_ROOT/Library/Fonts. You need to + organize font files in a certain way so that the art + backend can recognize them.

+ +

+ Check out these documents about installation and usage of nfonts: + + back-art Installation, + nfont + package.

+
+ + +
+ Encoding + +

+ By default, GNUstep assumes that a character is encoded in + ISO8859-1 unless the escape character \u precedes it (This + exception applies to other encodings). Hence, if you want to + use the characters of your native language with GNUstep, you + have to tell it which encoding you use. This can be done by + setting the environmental variable GNUSTEP_STRING_ENCODING to an + appropriate value. +

+ +

Some possible values for GNUSTEP_STRING_ENCODING are as follows:

+ + NSJapaneseEUCStringEncoding // Japanese + NSUTF8StringEncoding + NSISOLatin1StringEncoding // ISO-8859-1; West European + NSShiftJISStringEncoding // Japanese + NSISOLatin2StringEncoding // ISO-8859-2; East European + NSUnicodeStringEncoding + NSWindowsCP1251StringEncoding + NSWindowsCP1252StringEncoding // WinLatin1 + NSWindowsCP1253StringEncoding // Greek + NSWindowsCP1254StringEncoding // Turkish + NSWindowsCP1250StringEncoding // WinLatin2 + NSISO2022JPStringEncoding // Japanese + NSMacOSRomanStringEncoding + NSKOI8RStringEncoding // Russian/Cyrillic + NSISOLatin3StringEncoding // ISO-8859-3; South European + NSISOLatin4StringEncoding // ISO-8859-4; North European + NSISOCyrillicStringEncoding // ISO-8859-5 + NSISOArabicStringEncoding // ISO-8859-6 + NSISOGreekStringEncoding // ISO-8859-7 + NSISOHebrewStringEncoding // ISO-8859-8 + NSISOLatin5StringEncoding // ISO-8859-9; Turkish + NSISOLatin6StringEncoding // ISO-8859-10; Nordic + NSISOThaiStringEncoding // ISO-8859-11 + NSISOLatin7StringEncoding // ISO-8859-13 + NSISOLatin8StringEncoding // ISO-8859-14 + NSISOLatin9StringEncoding // ISO-8859-15; Replaces ISOLatin1 + NSGB2312StringEncoding + NSUTF7StringEncoding // RFC 2152 + NSGSM0338StringEncoding // GSM (mobile phone) default alphabet + NSBIG5StringEncoding // Traditional chinese + + +

+ Of these values, choose an appropriate one for your purpose and + set the environmental variable to it. For example, for sh or + bash, +

+ + export GNUSTEP_STRING_ENCODING=NSBIG5StringEncoding + + +

or, for csh,

+ + setenv GNUSTEP_STRING_ENCODING NSBIG5StringEncoding + +
+ +
- Default Encoding + User Default Values +

- GNUstep uses Unicode internally. Everything it reads will be - converted into Unicode. It will assume that everything it reads is in - NSISOLatin1StringEncoding (iso8859-1) as the default encoding except - scripts with escape (\u) ahead. User can change the default encoding - by setting the environment variable GNUSTEP_STRING_ENCODING. + Now that you specify the encoding, you have to determine which fonts you + use to display the characters of your native language.

+ +

Becuase the fonts used in GNUstep GUI are initially set to + those that are appropriate for European languages, you have to + overwrite them to display the characters correctly. +

+ +

At least, you need to change the user default value NSFont. + For example, suppose you have an .nfont package called MyFont + and want to use it to display the characters. To do this, use + the GNUstep's utility 'defaults' as follows:

-

For example, in bash:

- GNUSTEP_STRING_ENCODING = NSBIG5StringEncoding - export GNUSTEP_STRING_ENCODING + defaults write NSGlobalDomain NSFont "MyFont" + defaults write NSGlobalDomain NSFontSize 16 -

Now, it will assume that everything it reads without an escape is - NSBIG5StringEncoding (BIG5). GNUstep will also write anything into - this default encoding.

-

There is a handy tool to convert between encodings: - cvtenc. Programmers should use this tool to convert property - lists to Unicode before releasing them.

-
-
- Input -

In XWindows, GNUstep use the XIM input method. Any XIM-server - should be able to input script into GNUstep. The way GNUstep knows - the encoding of the input is from the environment variable - LC_CTYPE. In order to input Traditional Chinese, - LC_CTYPE must be set for example, in .xinitrc

- - LC_CTYPE=zh_TW.Big5 - export LC_CTYPE - -

Right now, GNUstep supports UTF8 and Big5 encoding in input. If it - doesn't work for your language, try to add more encoding support in - -initWithDelegate:display:name: - (back/Source/x11/XIMInputServer.m).

-
-
- Display -

Depending on the graphics library you use, GNUstep handles font - display slightly differently. You can choose the graphics library - when configuring the backend:

- - ./configure --enable-server=x11 --enable-graphics=xlib - -

the argument --enable-graphics could be either - xlib or art for now. Personally I would - suggest using art, which offer better font management.

-

You can specify the font and size you want to use with - the GNUstep defaults system. For exmample: -

- - defaults write NSGlobalDomain NSFont "Ar Pl Kaitim Big5" - defaults write NSGlobalDomain NSFontSize 16 - -

The font name should be the same as the font name of `xlsfonts` - output, but each word has to be capitalized. If you don't know - what font names GNUstep supports, use the font panel in Ink.app - to find out the font name.

-
-
- Xlib -

GNUstep will use a font cache in ~/GNUstep/Library/Font/Cache/ - to store the fonts of XWindows. Everytime you add more fonts to - XWindows, you have to delete this cache and let the program build a - new one. When you specify the default font, GNUstep will - look it up in the font cache, and pick up the matched font in XWindows, - then use this font to display text. GNUstep also support Xft for - anti-aliased font display. Add GSFontAntiAlias=YES to your defaults - to activate it. In order to use Traditional Chinese properly, always - set it. In order to use Xft, you also need to set freetype or - xtt in your XF86Config (most of the time this is done for you.)

-

Here is the problem you might meet when using Chinese fonts - (arphic) in GNUstep:

-

Each font will be assigned as big-0 or iso8859-1 - in fonts.dir by default, but actually arphic font is iso10646-1 - encoding. XWindows usually does the encoding conversion internally. So - when you use "Ar Pl Kaitim Big5", you have a - chance of picking up either big5-0 or iso8859-1 encoding, and neither - works for GNUstep for unknown reason. The solution is:

- - Add iso10646-1 in fonts.dir, and it has to be in front of - big5-0. Order is important to pick the right one. - Set the default GSFontMask = *-iso* so that font cache - won't pick up the big5-0 encoding. - -

That's it. GNUstep should pick up the right font - (iso10646-1). Since the mapping between NSFont in GNUstep (without - encoding information) and font in XWindows (with encoding - information) may not be unique ("Ar Pl Kaitim Big5" could be - "-arphic-ar pl kaitim big5-*-*..-big5-0" or "-arphic-ar pl kaitim - big5-*-*..-iso8859-1" or "-arphic-ar pl kaitim - big5-*-*..-iso10646-1"), you have to put the iso10646-1 font in - front of other encodings and use GSFontMask to filter out other - possible choices so that GNUstep can pick up the correct one. And - for now, I can only use the iso10646-1 font for Chinese - display. Font with other encoding (including big5) does not work - and is not well-tested.

-

If you still have problems, look at the - back/Source/xlib/XftFont.m and dump the font name of NSFont and - encoding of the corresponding XWindows font. Sometimes the font - cache can't find the matched XWindows font, and sometimes the - encoding of the XWindows font is different from what Xft got. An - example of the latter is that Xft will think the encoding of - "-arphic-ar pl kaitim big5-*-*..-big5-0" is "apple-roman". Only - "-arphic-ar pl kaitim big5-*-*..-iso10646-1" can be recognized as - "iso10646-1" correctly. Therefore, make sure GNUstep picks the right - XWindows font.

+ +

+ Depending on situation, you may also need to set NSUserFont to + the same font. For further details about the user default values, the + reader can refer to the documents DefaultsSummary.html and + NSFont.html shipped with the GNUstep packages. +

- Art -

The art backend use freetype for font management, and - minimizes encoding problems. Simply add a Chinese font into your - font collection as with other fonts, and enjoy the beautiful Chinese - characters.

+ Examples + + + Chinese + + + export GNUSTEP_STRING_ENCODING=NSBIG5StringEncoding + + + defaults write NSGlobalDomain NSFont "Ar Pl Kaitim Big5" + defaults write NSGlobalDomain NSFontSize 16 + + + + + Japanese + + + + + Korean + +
+
- Summary -

GNUstep supports internationalization and - localization. In a few steps, you should be able to use it with your - language.

- - Set GNUSTEP_STRING_ENCODING to read/write - locally encoded files, including Localizable.strings. - Set the correct LC_CTYPE. If your XIM-Server - doesn't support UTF8 or Big5 encoding, try to add your encoding - into XIMInputServer.m - Assign the font using the GNUstep defaults tool, and use - the art backend. - + Concluding Remarks + +

+ Although this article has focused on the CJK languages, most part of it + is also applicable to other languages if GNUstep supports the enconding + you need. +

+ +

+ If you find a way to set up GNUstep with your native language + other than CJK, please consider to contribute it to the GNUstep + community to share your invaluable experience with others. We'll + greatly appreciate it. Comments or suggestions are also welcome. +

-
+