NAME

TCOD::Tileset - Font loading functions

SYNOPSIS

use TCOD;

my $tileset = TCOD::Tileset->load_tilesheet(
    dist_file( TCOD => 'arial10x10.png' ),
    32, 8, TCOD::CHARMAP_TCOD,
);

DESCRIPTION

Tilesets encapsulate font loading functions.

Tilesets can be loaded as a whole from tile-sheets or True-Type fonts.

METHODS

load_tilesheet

$tileset = TCOD::Tileset->load_tilesheet( $path, $cols, $rows, $charmap );

Return a new TCOD::Tileset from a simple tilesheet PNG image. The location of this file in disk is specified in $path.

The values in $columns and $rows is the shape of the tileset. Tiles are assumed to take up the entire space of the image.

The value in $charmap is the character mapping to use. This is an array reference of codepoints which map the tiles like this:

$charmap->[ $tile_index ] = $codepoint

For common tilesets, $charmap should be the value in TCOD::CHARMAP_CP437.

There is no default value. If no value is provided, no tiles will be mapped. In this case, you'll need to use remap to assign codepoints to this tileset.

load_bdf

$tileset = TCOD::Tileset->load_bdf( $path );

Return a new TCOD::Tileset from a .bdf file.

For best results, the font should be monospace, cell-based, and single-width. As an example, a good set of fonts would be the Unicode fonts and tools for the X11 package.

tile_shape

( $width, $height ) = $tileset->tile_shape;

Returns a list with the width and height of the tile in pixels.

remap

$tileset->remap( $x, $y, $codepoint );

Reassign the Unicode codepoint specified in $codepoint to the character in this tilesheet at the position specified by the $x and $y coordinates.

This is the tile position itself, not the pixel position of the tile. Large values of $x will wrap to the next row, so using C$x> by itself is equivalent to Tile Index in the python-tcod Character Table Reference.

This is normally used on loaded tilesheets. Other methods of TCOD::Tileset creation won't have reliable tile indices.

SEE ALSO

TCOD
TCOD::Console

COPYRIGHT AND LICENSE

Copyright 2021 José Joaquín Atria

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.