Changes between Version 2 and Version 3 of UTF8Notes


Ignore:
Timestamp:
10/03/11 14:51:39 (8 years ago)
Author:
noz
Comment:

Added detail on internals and SDL port

Legend:

Unmodified
Added
Removed
Modified
  • UTF8Notes

    v2 v3  
    1111Angband now needs to be run within a UTF-8 capable locale, and this is checked in '''main.c''':''main()'', as: 
    1212{{{ 
    13         if (setlocale(LC_CTYPE, "")) { 
    14                 /* Require UTF-8 */ 
    15                 if (strcmp(nl_langinfo(CODESET), "UTF-8") != 0) 
    16                         quit("Angband requires UTF-8 support"); 
    17         } 
     13if (setlocale(LC_CTYPE, "")) { 
     14        /* Require UTF-8 */ 
     15        if (strcmp(nl_langinfo(CODESET), "UTF-8") != 0) 
     16                quit("Angband requires UTF-8 support"); 
     17} 
    1818}}} 
    1919 
     
    2929=== "Canvas" === 
    3030 
     31The internal representation of the main (and other terminal) screen(s) is as two arrays, one of "attributes" ('''byte attr''') and one of "characters" ('''wchar_t char'''). The characters to be displayed are stored as unicode, in the native wchar_t representation of a unicode character on the platform, whatever that is. When strings are printed to the screen, they are converted from UTF-8 (as '''char *''') to wide characters ('''wchar_t *''') using '''z-term.c''':''Term_mbstowcs()''. This allows the conversion function to be overloaded if a particular platform needs it. 
     32 
     33When they are displayed, the wide chars are put on the screen in different ways, depending on the port (see below). In the case of graphics tiles, things are slightly different. The "character" is still stored as a '''wchar_t''', but only the bottom 7 bits are used, as an index into a large 2-D bitmap, containing the tiles along the x axis, and the attributes ("colour") on the y axis. (''Check this bit'') In the original design, I had hoped to treat tiles as  a special case of a font, and allow all unicode character support, but the tiles are multi-coloured, so this cannot work.  
     34 
    3135=== Textblock === 
     36 
     37Textblocks (in '''z-textblock.c''') also have '''wchar_t''' as the internal representation of the displayed characters. These are then copied directly onto the canvas when the textblock is displayed. 
    3238 
    3339=== Parsers === 
     
    4248=== SDL === 
    4349 
     50Wide chars on the canvas are converted to a UTF-8 string using ''wcstombs()'' and then rendered to the screen using a pre-computed '''TTF_Font''' using ''TTF_RenderUTF8_Solid()'' in the function ''sdl_FontDraw()''. 
     51 
    4452=== X11 === 
    4553