Function tcod::get_height_rect

Function Documentation

inline int tcod::get_height_rect(int width, std::string_view str)

Return the height of the word-wrapped text with the given width.

auto console = tcod::Console{80, 50};
int y = console->h; // Start Y at the bottom of this console.
const int width = 6;
y -= tcod::get_height_rect("Long text example", width); // Move y up by the height of this text.
tcod::print(console, {0, y, width, 0}, "Long text example", std::nullopt, std::nullopt);

New in version 1.19.

Parameters
  • width – The maximum width of the bounding region in tiles.

  • str – The text to print. This string can contain libtcod color codes.

Returns

int The height of the text as if it were printed.