Angband with an accent: displaying extended characters
- From: Leon Marrick <none@xxxxxxxxxxx>
- Date: Sat, 15 Oct 2005 08:30:16 -0400
Angband with an accent
displaying extended characters
For almost as long as Angband has been in existance, people have wanted to display more than the basic ASCII set of 128 characters. If the game can be made to display a full byte range of 256 characters, then Tolkien names can be properly accented and special terrain can be made to look more distinctive.
However, results have been decidedly mixed. Fangband introduced accented artifact names long ago, but they only worked on IBM-PCs. The objective of this essay is to see how we can reproduce Fangband's success, and this time make it portable to multiple operating systems.
We discuss fonts first, because this is liable to be the hard part. The text file and code changes ought not to make us sweat unduly; they are treated afterwards. More details will be added as interested people chip in; would you like to help make this happen?
========== Discussion of 256-character fonts in various operating systems ================
Windows (Windows port):
The author works on Windows, so we will start the discussion there. It is easy for the Windows port to display 256 characters; all you have to do is edit a .fon file, put it into the /lib/xtra/font/ folder, and change fonts using the handy menu. An example of an edited font may be downloaded at:
http://www.runegold.org/angband/pub/8x13x.fon
This font has a series of special terrain icons in character positions 1-17, leaves positions 18-32 blank for variant terrain expansion, leaves positions 33-127 unchanged, adds a series of accented characters and monetary symbols (euro, pound, yen) in characters 128-165, and includes a Purple X Moria-style snake icon in position 159. The remaining character positions are left blank for additional customization.
More details on editing and using custom fonts for Windows may be found in Appendix A.
IBM/DOS/Windows (DOS and IBM ports):
Things aren't any more difficult here; this is the system that Fangband succeeded with. DOS (and the emulated DOS terminal available in Windows) can switch fonts. So can the IBM port. You take an existing font, edit it, add it to the font folder, and use it by revising "angdos.cfg" (DOS port, text mode).
(don't yet have a program to edit .fnt files, except for the old Angband one that works only on the IBM port's angband.fnt)
*** Here is where my knowledge ends. Everything from here on needs correction. ****
Linux and other graphical UNIX systems (X11, xaw, gtk, and other ports):
I have been told that Linux (and other UNIX graphical systems) do not allow ordinary users to use custom or application-specific fonts, that one has to be root and that the fonts have to be installed in some special way. One idea to work around this is to supply custom fonts as bitmap files in /lib/xtra/. Is there a reason why this wouldn't work for all graphical UNIX systems?
Macintosh (mac, carbon, and OS X ports):
If there is one operating system that glories in fonts, it is the Macintosh. I have been told that mac users have better font-handling tools than anyone. We shall see if this is so!
Terminals (various systems (other than IBM/DOS) without graphical capacity) (cap, gcu?):
People say that non-graphical terminals refuse to let the user change fonts. I'd be surprised if that were really so but, for argument's sake, let us assume that it is. This brings us to:
============== Implementation and Compatibility ==================
OK. So we have some systems that can handle 256-character fonts, and some that either can't, or that haven't got extended fonts. We need a way for accented names and other special characters to be 1) translated into the correct characters for that system (they differ), and 2) translated into basic ASCII characters if that is all that are available.
When working on getting 256 colors, among my priorities was to stay compatible with both GCU and IBM, both 16-color ports. This required that each "extended" color have a 16-color translation. The same method will work just dandy for extended characters.
Consider an accented name, such as Luthien. In "artifact.txt", it is listed as:
# The Shadow Cloak of Luthien
N:49:of Luthien I:35:6:2 W:40:40:5:45000 P:6:0d0:0:0:20
We want a forward slant accent over that u. Let's change this to:
# The Shadow Cloak of Luthien
N:49:of L^'uthien # see explanation below I:35:6:2 W:40:40:5:45000 P:6:0d0:0:0:20
Now for some coding.
In the text file pharser, we need something to look at a name. When it sees a " ^ ", it looks at the second character to figure out what accent to apply. In this case, we have a forward single quote (" ' "), which means forward slant accent. The third character is the letter itself; in this case, a lowercase " u ".
We now need a lookup table. Each character set will have a different character that shows a lowercase u with a forward slant accent. So we add a preference type, write up the various possible combinations for recognized accented characters, and let the game read them into a table on load. If two systems have differing character sets, then we just have different preference lists for them.
Now we make our move to keep this compatable with 128-character systems. Whenever we reach the end of our lookup table without finding the correct accented character, we ignore the accent and use the plain ASCII "u" for the data file. So people can admire Luthien with or without accent.
One more wrinkle. The game stores characters as signed bytes. The input text feeds it unsigned bytes. Translating between the two is child's play, we just have to remember to do it consistantly.
========================
Appendix A: Editing and installing custom fonts for the Angband Windows port.
I assume you have a clean copy of Angband 3.0.6 for this discussion. The methods outlined below will also work for most modern variants.
1. Download softy, a shareware bitmap font editor, and upzip it. http://users.breathe.com/l-emmett/
2. Copy an Angband font that you know works to the softy directory - in this example, we shall copy 8x13.fon. Fire softy up. Notice the request for money; this program is not freeware.
3. Menu "Font Type -> bitmap". The Bitmap window opens; in this window, use Menu File -> Open. Choose the font.
4. Your font should now appear. Edit the font header first: use Menu Font -> Header..., and a dialog box with font header information appears. Change the font name from (in this example) 8x13 to 8x13a. The new name must 1) be unique within the Angband fonts folder, and 2) start with the width and height of the font. All Angband's existing fonts already do both of these things. When done, click "OK".
5. Edit one character (you might try the '@' symbol). Don't spend much time, just enough so your work is obvious. The Angband Windows font reader is fairly unforgiving of newbie mistakes, and you need to make sure you know how to get the game to recognize your fonts before spending time on individual characters.
6. Click on some other character. The program will ask if you want to save the character you've been working on. Carefully say yes. Notice the character list update.
7. Now that the header name is unique, and any changed characters are properly closed, you may now save the font. Menu File -> Save As. Save under *exactly* the same name as appears in your font header, plus the ..fon file extension. In our case, we will save as "8x13a.fon". Double-check that you are either making a new font or overwriting a font. Do not let softy add your new font to an existing one; Angband doesn't understand font packages.
8. Close softy. Copy the font to your Angband game's /lib/xtra/fonts folder (where all the other .fon files live).
9. Fire up Angband. Change to text mode if you see graphics. Use the menu and select Window -> Font -> Term-0 window. Choose your new font.
Test #1: Look carefully at the screen. If the overall appearance of the font has worsened or it just looksdull or "strange", then your font is not recognized by the game. The most probable reasons are that your font's header is different than the file name (before the .fon bit), or you have two or more fonts saved in a common file.
Test #2: Command '%' - Interact with Visuals. Change the player icon to your new edited character. If test #1 succeeds, then this test probably will too. However, if you simply cannot see your edited character, and you are certain you are using your new font, then restart the game. If this doesn't work, reboot your machine.
If either test fails, try, try again. When both succeed, great!
-- S(all) W/X H+ D c+ f? PV++ s? d- C S !I? !So? RQ V+ F:<<too much data!>> (website for Angband code down) .
- Follow-Ups:
- Re: Angband with an accent: displaying extended characters
- From: Hugo Kornelis
- Re: Angband with an accent: displaying extended characters
- From: Matthias Kurzke
- Re: Angband with an accent: displaying extended characters
- From: Jeff Greene
- Re: Angband with an accent: displaying extended characters
- From: pete mack
- Re: Angband with an accent: displaying extended characters
- From: Hallvard B Furuseth
- Re: Angband with an accent: displaying extended characters
- From: Andrew Sidwell
- Re: Angband with an accent: displaying extended characters
- From: Christophe Cavalaria
- Re: Angband with an accent: displaying extended characters
- From: Joshua Rodman
- Re: Angband with an accent: displaying extended characters
- Prev by Date: Re: Martial arts re-nerfed? [S]
- Next by Date: Re: Angband with an accent: displaying extended characters
- Previous by thread: Martial arts re-nerfed? [S]
- Next by thread: Re: Angband with an accent: displaying extended characters
- Index(es):
Relevant Pages
|