tcod.tileset

Tileset and font related functions.

class tcod.tileset.Tileset(tile_width: int, tile_height: int)[source]

A collection of graphical tiles.

This class is provisional, the API may change in the future.

__contains__(codepoint: int) → bool[source]

Test if a tileset has a codepoint with n in tileset.

get_tile(codepoint: int) → numpy.array[source]

Return a copy of a tile for the given codepoint.

If the tile does not exist yet then a blank array will be returned.

The tile will have a shape of (height, width, rgba) and a dtype of uint8. Note that most grey-scale tiles will only use the alpha channel and will usually have a solid white color channel.

set_tile(codepoint: int, tile: numpy.array) → None[source]

Upload a tile into this array.

The tile can be in 32-bit color (height, width, rgba), or grey-scale (height, width). The tile should have a dtype of np.uint8.

This data may need to be sent to graphics card memory, this is a slow operation.

tile_height

The height of the tile in pixels.

tile_shape

The shape (height, width) of the tile in pixels.

tile_width

The width of the tile in pixels.

tcod.tileset.get_default() → tcod.tileset.Tileset[source]

Return a reference to the default Tileset.

This function is provisional. The API may change.

tcod.tileset.load_truetype_font(path: str, tile_width: int, tile_height: int) → tcod.tileset.Tileset[source]

Return a new Tileset from a .ttf or .otf file.

Same as set_truetype_font, but returns a Tileset instead. You can send this Tileset to set_default.

This function is provisional. The API may change.

tcod.tileset.set_default(tileset: tcod.tileset.Tileset) → None[source]

Set the default tileset.

The display will use this new tileset immediately.

This function only affects the SDL2 and OPENGL2 renderers.

This function is provisional. The API may change.

tcod.tileset.set_truetype_font(path: str, tile_width: int, tile_height: int) → None[source]

Set the default tileset from a .ttf or .otf file.

path is the file path for the font file.

tile_width and tile_height are the desired size of the tiles in the new tileset. The font will be scaled to fit the given tile_height and tile_width.

This function will only affect the SDL2 and OPENGL2 renderers.

This function must be called before tcod.console_init_root. Once the root console is setup you may call this funtion again to change the font. The tileset can be changed but the window will not be resized automatically.

New in version 9.2.