Thursday 15 January 2015

Incursion PDCurses problems

Switching to the wide character API, the main problem was that the way Incursion encoded it's glyphs was incompatible.  Glyphs are encoded in the form 0xBFCC, where B is the index of the background colour, F is the index of the foreground colour and CC is the 8 bit character code.  F was generally put in place by doing F*256.   To increase the size of character codes, required widespread changes and searching and dealing with a variety of integer values which were involved.

The lower level engine also now uses non-representative values for it's glyph codes.  Mapping to character codes is done in each of the UI layers.

Unfortunately there are some teething problems with getting a working set of character codes.  The red question marks in the following image are GLYPH_FLOOR2, but the UTF-16 code chosen is not available in the default DOS console font.


So, what is the font?  Apparently, it's Terminal.


Here is the Terminal character set.


I knocked up a wizard menu option to dump the glyphs out.


Note that there are characters here which are from a proper UTF-16 font.  Take for example ARROW RIGHT, ARROW LEFT, ARROW UP and ARROW DOWN in the fourth and third to last rows.  Where do they come from?  No idea!  Another question is why does the first glyph for PERSON cause a missing space and the first row to be misaligned?  No idea!

One question I have is whether it is possible to detect missing glyphs and dynamically substitute them.  Curses has an API which allows the character at a given coordinate to be queried.  If I write an character unsupported by the current font, and query it back, do I get the code I wrote or the code that gets displayed?

3 comments:

  1. In UTF-16, the cent sign is value 0x00A2*, whereas the e.g. right arrow is 0x2192**. I suspect your renderer is skipping the 0x00 byte when calculating a length somewhere.

    * http://www.fileformat.info/info/unicode/char/a2/index.htm
    ** http://www.fileformat.info/info/unicode/char/2192/index.htm

    ReplyDelete
    Replies
    1. Note that there are 0x00?? and 0x???? characters that are both displaying fine. If this is a problem, it's one in PDCurses, or perhaps a font problem in Windows. Not much I can do about it.

      Delete