libtcod
Loading...
Searching...
No Matches
Printing (Unicode)

Printing functions supporting UTF-8 strings. More...

Classes

struct  TCOD_PrintParamsRGB
 Information about a string to be printed. More...
 

Typedefs

typedef struct TCOD_PrintParamsRGB TCOD_PrintParamsRGB
 Information about a string to be printed.
 

Functions

TCOD_Error TCOD_console_printf (TCOD_Console *con, int x, int y, const char *fmt,...)
 Format and print a UTF-8 string to a console.
 
TCOD_Error TCOD_console_printf_ex (TCOD_Console *con, int x, int y, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt,...)
 Format and print a UTF-8 string to a console.
 
int TCOD_console_printf_rect (TCOD_Console *con, int x, int y, int w, int h, const char *fmt,...)
 Format and print a UTF-8 string to a console.
 
int TCOD_console_printf_rect_ex (TCOD_Console *con, int x, int y, int w, int h, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt,...)
 Format and print a UTF-8 string to a console.
 
TCOD_Error TCOD_console_printf_frame (TCOD_Console *con, int x, int y, int w, int h, int empty, TCOD_bkgnd_flag_t flag, const char *fmt,...)
 Print a framed and optionally titled region to a console, using default colors and alignment.
 
int TCOD_console_get_height_rect_fmt (TCOD_Console *con, int x, int y, int w, int h, const char *fmt,...)
 Return the number of lines that would be printed by this formatted string.
 
TCOD_Error TCOD_console_printn (TCOD_Console *console, int x, int y, size_t n, const char *str, const TCOD_ColorRGB *fg, const TCOD_ColorRGB *bg, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment)
 Print a string of a specified length to a console.
 
int TCOD_console_printn_rect (TCOD_Console *console, int x, int y, int width, int height, size_t n, const char *str, const TCOD_ColorRGB *fg, const TCOD_ColorRGB *bg, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment)
 Print a string of a specified length in a bounding box to a console.
 
int TCOD_console_get_height_rect_n (TCOD_Console *console, int x, int y, int width, int height, size_t n, const char *str)
 Return the height of the word-wrapped text with the given parameters.
 
int TCOD_console_get_height_rect_wn (int width, size_t n, const char *str)
 Return the height of the word-wrapped text with the given width.
 
TCOD_Error TCOD_console_printn_frame (TCOD_Console *console, int x, int y, int width, int height, size_t n, const char *title, const TCOD_ColorRGB *fg, const TCOD_ColorRGB *bg, TCOD_bkgnd_flag_t flag, bool clear)
 
TCOD_Error TCOD_console_vprintf (TCOD_Console *console, int x, int y, const TCOD_color_t *fg, const TCOD_color_t *bg, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, va_list args)
 Print a formatted string using a va_list.
 
int TCOD_console_vprintf_rect (TCOD_Console *console, int x, int y, int width, int height, const TCOD_color_t *fg, const TCOD_color_t *bg, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment, const char *fmt, va_list args)
 Print a formatted string using a va_list within a bounding box.
 
int TCOD_printf_rgb (TCOD_Console *console, TCOD_PrintParamsRGB params, const char *fmt,...)
 Prints a formatted string to the console.
 
int TCOD_printn_rgb (TCOD_Console *console, TCOD_PrintParamsRGB params, int n, const char *str)
 Prints n-bytes of a string string to the console.
 
int TCOD_vprintf_rgb (TCOD_Console *console, TCOD_PrintParamsRGB params, const char *fmt, va_list args)
 Prints a formatted string using va_list.
 

Detailed Description

Printing functions supporting UTF-8 strings.

Function Documentation

◆ TCOD_console_get_height_rect_fmt()

int TCOD_console_get_height_rect_fmt ( TCOD_Console * con,
int x,
int y,
int w,
int h,
const char * fmt,
... )

Return the number of lines that would be printed by this formatted string.

\rst .. versionadded:: 1.8

.. versionchanged:: 1.16 Now returns a negative error code on failure. \endrst

◆ TCOD_console_get_height_rect_n()

int TCOD_console_get_height_rect_n ( TCOD_Console * console,
int x,
int y,
int width,
int height,
size_t n,
const char * str )

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

Parameters
consoleA pointer to a TCOD_Console.
xThe starting X position, starting from the left-most tile as zero.
yThe starting Y position, starting from the upper-most tile as zero.
widthThe maximum width of the bounding region in tiles.
heightThe maximum height of the bounding region in tiles.
nThe length of the string buffer str[n] in bytes.
strThe text to print. This string can contain libtcod color codes.
Returns
int The height of the word-wrapped text as if it were printed, or a negative error code on failure.

@versionadded{1.19}

◆ TCOD_console_get_height_rect_wn()

int TCOD_console_get_height_rect_wn ( int width,
size_t n,
const char * str )

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

Parameters
widthThe maximum width of the bounding region in tiles.
nThe length of the string buffer str[n] in bytes.
strThe text to print. This string can contain libtcod color codes.
Returns
int The height of the word-wrapped text as if it were printed, or a negative error code on failure.

@versionadded{1.19}

◆ TCOD_console_printf()

TCOD_Error TCOD_console_printf ( TCOD_Console * con,
int x,
int y,
const char * fmt,
... )

Format and print a UTF-8 string to a console.

\rst .. versionadded:: 1.8

.. versionchanged:: 1.16 Now returns a negative error code on failure. \endrst

◆ TCOD_console_printf_ex()

TCOD_Error TCOD_console_printf_ex ( TCOD_Console * con,
int x,
int y,
TCOD_bkgnd_flag_t flag,
TCOD_alignment_t alignment,
const char * fmt,
... )

Format and print a UTF-8 string to a console.

\rst .. versionadded:: 1.8

.. versionchanged:: 1.16 Now returns a negative error code on failure. \endrst

◆ TCOD_console_printf_frame()

TCOD_Error TCOD_console_printf_frame ( TCOD_Console * con,
int x,
int y,
int w,
int h,
int empty,
TCOD_bkgnd_flag_t flag,
const char * fmt,
... )

Print a framed and optionally titled region to a console, using default colors and alignment.

This function uses Unicode box-drawing characters and a UTF-8 formatted string. \rst .. versionadded:: 1.8

.. versionchanged:: 1.16 Now returns a negative error code on failure. \endrst

◆ TCOD_console_printf_rect()

int TCOD_console_printf_rect ( TCOD_Console * con,
int x,
int y,
int w,
int h,
const char * fmt,
... )

Format and print a UTF-8 string to a console.

\rst .. versionadded:: 1.8

.. versionchanged:: 1.16 Now returns a negative error code on failure. \endrst

◆ TCOD_console_printf_rect_ex()

int TCOD_console_printf_rect_ex ( TCOD_Console * con,
int x,
int y,
int w,
int h,
TCOD_bkgnd_flag_t flag,
TCOD_alignment_t alignment,
const char * fmt,
... )

Format and print a UTF-8 string to a console.

\rst .. versionadded:: 1.8

.. versionchanged:: 1.16 Now returns a negative error code on failure. \endrst

◆ TCOD_console_printn()

TCOD_Error TCOD_console_printn ( TCOD_Console * console,
int x,
int y,
size_t n,
const char * str,
const TCOD_ColorRGB * fg,
const TCOD_ColorRGB * bg,
TCOD_bkgnd_flag_t flag,
TCOD_alignment_t alignment )

Print a string of a specified length to a console.

Parameters
consoleA pointer to a TCOD_Console.
xThe starting X position, starting from the left-most tile as zero.
yThe starting Y position, starting from the upper-most tile as zero.
nThe length of the string buffer str[n] in bytes.
strThe text to print. This string can contain libtcod color codes.
fgThe foreground color. The printed text is set to this color. If NULL then the foreground will be left unchanged, inheriting the previous value of the tile.
bgThe background color. The background tile under the printed text is set to this color. If NULL then the background will be left unchanged.
flagThe background blending flag. If unsure then use TCOD_BKGND_SET.
alignmentThe text justification. This is one of TCOD_alignment_t and is normally TCOD_LEFT.
Returns
TCOD_Error Any problems such as malformed UTF-8 will return a negative error code.

@versionadded{1.19}

◆ TCOD_console_printn_rect()

int TCOD_console_printn_rect ( TCOD_Console * console,
int x,
int y,
int width,
int height,
size_t n,
const char * str,
const TCOD_ColorRGB * fg,
const TCOD_ColorRGB * bg,
TCOD_bkgnd_flag_t flag,
TCOD_alignment_t alignment )

Print a string of a specified length in a bounding box to a console.

Parameters
consoleA pointer to a TCOD_Console.
xThe starting X position, starting from the left-most tile as zero.
yThe starting Y position, starting from the upper-most tile as zero.
widthThe maximum width of the bounding region in tiles.
heightThe maximum height of the bounding region in tiles.
nThe length of the string buffer str[n] in bytes.
strThe text to print. This string can contain libtcod color codes.
fgThe foreground color. The printed text is set to this color. If NULL then the foreground will be left unchanged, inheriting the previous value of the tile.
bgThe background color. The background tile under the printed text is set to this color. If NULL then the background will be left unchanged.
flagThe background blending flag. If unsure then use TCOD_BKGND_SET.
alignmentThe text justification. This is one of TCOD_alignment_t and is normally TCOD_LEFT.
Returns
int The height of the printed text, or a negative error code on failure.

@versionadded{1.19}

◆ TCOD_console_vprintf()

TCOD_Error TCOD_console_vprintf ( TCOD_Console * console,
int x,
int y,
const TCOD_color_t * fg,
const TCOD_color_t * bg,
TCOD_bkgnd_flag_t flag,
TCOD_alignment_t alignment,
const char * fmt,
va_list args )

Print a formatted string using a va_list.

Parameters
consoleA pointer to a TCOD_Console.
xThe starting X position, starting from the left-most tile as zero.
yThe starting Y position, starting from the upper-most tile as zero.
fgThe foreground color. The printed text is set to this color. If NULL then the foreground will be left unchanged, inheriting the previous value of the tile.
bgThe background color. The background tile under the printed text is set to this color. If NULL then the background will be left unchanged.
flagThe background blending flag. If unsure then use TCOD_BKGND_SET.
alignmentThe text justification. This is one of TCOD_alignment_t and is normally TCOD_LEFT.
fmtThe format string for a vprintf-like function.
argsThe arguments for the formatted string.
Returns
TCOD_Error Any problems such as malformed UTF-8 will return a negative error code.

@versionadded{1.19}

◆ TCOD_console_vprintf_rect()

int TCOD_console_vprintf_rect ( TCOD_Console * console,
int x,
int y,
int width,
int height,
const TCOD_color_t * fg,
const TCOD_color_t * bg,
TCOD_bkgnd_flag_t flag,
TCOD_alignment_t alignment,
const char * fmt,
va_list args )

Print a formatted string using a va_list within a bounding box.

Parameters
consoleA pointer to a TCOD_Console.
xThe starting X position, starting from the left-most tile as zero.
yThe starting Y position, starting from the upper-most tile as zero.
widthThe maximum width of the bounding region in tiles.
heightThe maximum height of the bounding region in tiles.
fgThe foreground color. The printed text is set to this color. If NULL then the foreground will be left unchanged, inheriting the previous value of the tile.
bgThe background color. The background tile under the printed text is set to this color. If NULL then the background will be left unchanged.
flagThe background blending flag. If unsure then use TCOD_BKGND_SET.
alignmentThe text justification. This is one of TCOD_alignment_t and is normally TCOD_LEFT.
fmtThe format string for a vprintf-like function.
argsThe arguments for the formatted string.
Returns
int The height of the printed text, or a negative error code on failures.

@versionadded{1.19}

◆ TCOD_printf_rgb()

int TCOD_printf_rgb ( TCOD_Console * console,
TCOD_PrintParamsRGB params,
const char * fmt,
... )

Prints a formatted string to the console.

Parameters
consoleA pointer to a TCOD_Console.
paramsInformation about how the string should be printed
fmtThe format string for a vprintf-like function.
argsThe arguments for the formatted string.
Returns
An error code if less than 0
embed:rst:leading-asterisk
 .. versionadded:: 1.23

◆ TCOD_printn_rgb()

int TCOD_printn_rgb ( TCOD_Console * console,
TCOD_PrintParamsRGB params,
int n,
const char * str )

Prints n-bytes of a string string to the console.

Parameters
consoleA pointer to a TCOD_Console.
paramsInformation about how the string should be printed
strThe string to be read from.
nLength of string in bytes
Returns
An error code if less than 0
embed:rst:leading-asterisk
 .. versionadded:: 1.23

◆ TCOD_vprintf_rgb()

int TCOD_vprintf_rgb ( TCOD_Console * console,
TCOD_PrintParamsRGB params,
const char * fmt,
va_list args )

Prints a formatted string using va_list.

Parameters
consoleA pointer to a TCOD_Console.
paramsInformation about how the string should be printed
fmtThe format string for a vprintf-like function
argsThe arguments for the format string
Returns
An error code if less than 0
embed:rst:leading-asterisk
 .. versionadded:: 1.23