libtonc
|
A generalized raster text system. More...
Modules | |
Operations | |
Basic operations. | |
Attributes | |
Basic getters and setters. | |
Console IO | |
Stdio functionality. | |
Tilemap text | |
Text for regular and affine tilemaps. | |
Character text, column-major | |
Text on surface composed of 4bpp tiles, mapped in column-major order. | |
Character text, row-major | |
Text on surface composed of 4bpp tiles, mapped in row-major order. | |
Bitmap text | |
Text for 16bpp and 8bpp bitmap surfaces: modes 3, 4 and 5. | |
Object text | |
Text using objects. | |
Data Structures | |
struct | TFont |
Font description struct. More... | |
struct | TTC |
TTE context struct. More... | |
Macros | |
#define | TTE_TAB_WIDTH 24 |
Default initializers | |
typedef void(* | fnDrawg) (uint gid) |
Glyph render function format. | |
typedef void(* | fnErase) (int left, int top, int right, int bottom) |
Erase rectangle function format. | |
typedef struct TFont | TFont |
Font description struct. | |
typedef struct TTC | TTC |
TTE context struct. | |
TTC * | gp_tte_context |
Glyph render function format. | |
#define | tte_init_se_default(bgnr, bgcnt) tte_init_se( bgnr, bgcnt, 0xF000, CLR_YELLOW, 0, &fwf_default, NULL) |
Glyph render function format. | |
#define | tte_init_ase_default(bgnr, bgcnt) tte_init_ase(bgnr, bgcnt, 0x0000, CLR_YELLOW, 0, &fwf_default, NULL) |
Glyph render function format. | |
#define | tte_init_chr4c_default(bgnr, bgcnt) |
Glyph render function format. | |
#define | tte_init_chr4r_default(bgnr, bgcnt) |
Glyph render function format. | |
#define | tte_init_chr4c_b4_default(bgnr, bgcnt) |
Glyph render function format. | |
#define | tte_init_bmp_default(mode) tte_init_bmp(mode, &vwf_default, NULL) |
Glyph render function format. | |
#define | tte_init_obj_default(pObj) tte_init_obj(pObj, 0, 0, 0xF000, CLR_YELLOW, 0, &fwf_default, NULL) |
Glyph render function format. | |
Internal fonts | |
const TFont | sys8Font |
System font ' '-127. FWF 8x 8@1. | |
const TFont | verdana9Font |
Verdana 9 ' '-'ÿ'. VWF 8x12@1. | |
const TFont | verdana9bFont |
Verdana 9 bold ' '-'ÿ'. VWF 8x12@1. | |
const TFont | verdana9iFont |
Verdana 9 italic ' '-'ÿ'. VWF 8x12@1. | |
const TFont | verdana10Font |
Verdana 10 ' '-'ÿ'. VWF 16x14@1. | |
const TFont | verdana9_b4Font |
Verdana 9 ' '-'ÿ'. VWF 8x12@4. | |
const unsigned int | sys8Glyphs [192] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned int | verdana9Glyphs [896] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned char | verdana9Widths [224] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned int | verdana9bGlyphs [896] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned char | verdana9bWidths [224] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned int | verdana9iGlyphs [896] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned char | verdana9iWidths [224] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned int | verdana10Glyphs [1792] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned char | verdana10Widths [224] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned int | verdana9_b4Glyphs [3584] |
System font ' '-127. FWF 8x 8@1. | |
const unsigned char | verdana9_b4Widths [224] |
System font ' '-127. FWF 8x 8@1. | |
Color lut indices | |
#define | TTE_INK 0 |
#define | TTE_SHADOW 1 |
#define | TTE_PAPER 2 |
#define | TTE_SPECIAL 3 |
drawg helper macros | |
#define | TTE_BASE_VARS(_tc, _font) |
Declare and define base drawg variables. | |
#define | TTE_CHAR_VARS(font, gid, src_t, _sD, _sL, _chW, _chH) |
Declare and define basic source drawg variables. | |
#define | TTE_DST_VARS(tc, dst_t, _dD, _dL, _dP, _x, _y) |
Declare and define basic destination drawg variables. | |
Default fonts | |
#define | fwf_default sys8Font |
Default fixed-width font. | |
#define | vwf_default verdana9Font |
Default vairable-width font. | |
Default glyph renderers | |
#define | ase_drawg_default ((fnDrawg)ase_drawg_s) |
#define | bmp8_drawg_default ((fnDrawg)bmp8_drawg_b1cts) |
#define | bmp16_drawg_default ((fnDrawg)bmp16_drawg_b1cts) |
#define | chr4c_drawg_default ((fnDrawg)chr4c_drawg_b1cts) |
#define | chr4r_drawg_default ((fnDrawg)chr4r_drawg_b1cts) |
#define | obj_drawg_default ((fnDrawg)obj_drawg) |
#define | se_drawg_default ((fnDrawg)se_drawg_s) |
A generalized raster text system.
As of v1.3, Tonc has a completely new way of handling text. It can handle (practically) all modes, VRAM types and font sizes and brings them together under a unified interface. It uses function pointers to store drawg and erase functions of each rendering family. The families currently supported are:
Each of these consists of an initializer, tte_init_foo
, and one or more glyph rendering functions, foo_puts_bar
, The bar
part of the renderer denotes the style of the particular renderer, which can indicate:
- Expected bitdepth of font data (\c b1 for 1bpp, etc) - Expected sizes of the character (\c w8 and h8, for example). - Application of system colors (\c c ). - Transparent or opaque background pixels (\c t or \c o ). - Whether the font-data is in 'strip' layout (\c s )
The included renderers here are usually transparent, recolored, using 1bpp strip glyphs (_b1cts
). The initializer takes a bunch of options specific to each family, as well as font and renderer pointers. You can provide your own font and renderers, provided they're formatted correcty. For the default font/renderers, use NULL
.
After the calling the initializer, you can write utf-8 encoded text with tte_write() or tte_write_ex(). You can also enable stdio-related functions by calling tte_init_con().
The system also supposed rudimentary scripting for positions, colors, margins and erases. See tte_cmd_default() and con_cmd_parse() for details.
#define TTE_BASE_VARS | ( | _tc, | |
_font | |||
) |
Declare and define base drawg variables.
Each drawg
renderer usually starts with the same thing:
#define TTE_CHAR_VARS | ( | font, | |
gid, | |||
src_t, | |||
_sD, | |||
_sL, | |||
_chW, | |||
_chH | |||
) |
Declare and define basic source drawg variables.
#define TTE_DST_VARS | ( | tc, | |
dst_t, | |||
_dD, | |||
_dL, | |||
_dP, | |||
_x, | |||
_y | |||
) |
Declare and define basic destination drawg variables.
#define tte_init_chr4c_b4_default | ( | bgnr, | |
bgcnt | |||
) |
Glyph render function format.
#define tte_init_chr4c_default | ( | bgnr, | |
bgcnt | |||
) |
Glyph render function format.
#define tte_init_chr4r_default | ( | bgnr, | |
bgcnt | |||
) |
Glyph render function format.
Font description struct.
The TFont
contains a description of the font, including pointers to the glyph data and width data (for VWF fonts), an ascii-offset for when the first glyph isn't for ascii-null (which is likely. Usually it starts at ' ' (32)).
The font-bitmap is a stack of cells, each containing one glyph each. The cells and characters need not be the same size, but the character glyph must fit within the cell.
The formatting of the glyphs themselves should fit the rendering procedure. The default renderers use 1bpp 8x8 tiled graphics, where for multi-tiled cells the tiles are in a vertical 'strip' format. In an 16x16 cell, the 4 tiles would be arranged as:
0 | 2 |
1 | 3 |