This is the first post of a series of articles about GNUstep applications. The purpose is to introduce useful GNUstep applications to regular users and provides some tips. These applications can be used on daily basis, though it doesn't mean they are perfect or bug-free. Any problem should be reported to the original authors or in GNUstep maillist.
Gomoku is an extended TicTacToe game for GNUstep. It is small and fun to play. You first click on the board to put a white piece, then try to have 5 white pieces adjacent to each other horizontally, vertically or diagonally like this:
If you think it is too easy, you can increase the difficulty under Info menu:
Now, computer seems very smart:
You can also increase the size of board by executing it with the size of board like this:
openapp ./Gomoku.app 10
The size must be bigger than 8.
Gomoku is a good example to test internationalization (i18n) and localization (i10n) in GNUstep because it is small and simple to do so. It is already localized in 9 languages and you should have no problem using it with your native language. In some cases, depending on your system, you may have some difficulties to see your native language. This article summarizes the steps to take for art backend. Here shows another example in cairo backend. The steps are mostly identical.
GNUstep is smart enough to guess your language, Execute `echo $LANG` or `echo $LC_CTYPE` to know your locale. In my case, it is en_US.UTF8. So my system is in UTF8 encoding and uses English. If I decide to use German in Gomoku, I have to specify the language in user defaults by executing
defaults write NSGlobalDomain NSLanguages "(German, English)"
It tells GNUstep to find the German localization first, then English. Unfortunately, it is not enough for me. The German localization is in different encoding than mine (UTF8). I guess it is in ISO 8859-1 encoding. So I set an environment variable GNUSTEP_STRING_ENCODING like this:
Now, the menu is in German:
Note both NSLanguages and GNUSTEP_STRING_ENCODING affect all GNUstep applications.
If I want to go further to use Traditional Chinese, the default font of GNUstep may not have Chinese characters in it. So I need to specify the default font by doing this:
defaults write NSGlobalDomain NSFont "AR PL ShanHeiSun Uni"
And select the language and encoding:
defaults write NSGlobalDomain NSLanguages "(TraditionalChinese, English)"
Now, it shows Chinese:
If you work on many languages and specifying a single font for NSFont doesn't suit you, you can try NSPreferredFonts, but it only works on art backend. First, you can download pre-packed fonts from Étoilé Project. Look for etoile-default-fonts.tar.gz. Unpack and move the nfont package (.nfont) into your ~/GNUstep/Library/Fonts/ or in the system GNUstep/System/Library/Fonts/. Then specify the preferred fonts:
defaults delete NSGlobalDomain NSFont
defaults write NSGlobalDomain NSPreferredFonts '("ShanHeiSun-Uni")'
In this way, GNUstep will try to use the preferred fonts if it cannot find the glyphs in the default font. Again, it only works for art backend for now. If you do not specify NSPreferredFonts, GNUstep will go through all of your fonts to find the glyphs, It may pick up the font you don't like. So it is better to specify the NSPreferredFonts.
For developers who wants to support NSPreferredFonts in cairo backend, try to implement -coveredCharacterSet and -numberOfGlyphs in back/Source/cairo/CairoFontInfo.m. You can use back/Source/art/ftfont.m as a reference.