# Text output

- allegro_404_char
- destroy_font
- font
- text_height
- text_length
- text_mode
- textout
- textout_centre
- textout_centre_ex
- textout_ex
- textout_justify
- textout_justify_ex
- textout_right
- textout_right_ex
- textprintf
- textprintf_centre
- textprintf_centre_ex
- textprintf_ex
- textprintf_justify
- textprintf_justify_ex
- textprintf_right
- textprintf_right_ex

Allegro provides text output routines that work with both monochrome and color fonts, which can contain any number of Unicode character ranges. The grabber program can create fonts from sets of characters drawn in a bitmap file (see grabber.txt for more information), and can also import GRX or BIOS format font files. The font structure contains a number of hooks that can be used to extend it with your own custom drawing code: see the definition in allegro/text.h for details.

extern FONT *font;
A simple 8x8 fixed size font (the mode 13h BIOS default). If you want to alter the font used by the GUI routines, change this to point to one of your own fonts. This font contains the standard ASCII (U+20 to U+7F), Latin-1 (U+A1 to U+FF), and Latin Extended-A (U+0100 to U+017F) character ranges.

> See also: textout_ex, textprintf_ex.

extern int allegro_404_char;
When Allegro cannot find a glyph it needs in a font, it will instead output the character given in allegro_404_char. By default, this is set to the caret symbol, '^'.

> See also: font.

int text_length(const FONT *f, const char *str);
Returns the length (in pixels) of a string in the specified font.

> See also: text_height.

int text_height(const FONT *f)
Returns the height (in pixels) of the specified font.

> See also: text_length.

void destroy_font(FONT *f);
Frees the memory being used by a font structure.

void textout_ex(BITMAP *bmp, const FONT *f, const char *s, int x, y, color, bg);
Writes the string s onto the bitmap at position x, y, using the specified font, foreground color and background color. If the background color is -1, then the text is written transparently. If the foreground color is -1 and a color font is in use, it will be drawn using the colors from the original font bitmap (the one you imported into the grabber program), which allows multicolored text output.

> See also: font, textout_centre_ex, textout_right_ex, textout_justify_ex, textprintf_ex, text_height, text_length.

void textout_centre_ex(BITMAP *bmp, const FONT *f, const char *s, int x, y, color, bg);
Like textout_ex(), but interprets the x coordinate as the centre rather than the left edge of the string.

> See also: textout_ex, textprintf_centre_ex.

void textout_right_ex(BITMAP *bmp, const FONT *f, const char *s, int x, y, color, bg);
Like textout_ex(), but interprets the x coordinate as the right rather than the left edge of the string.

> See also: textout_ex, textprintf_right_ex.

void textout_justify_ex(BITMAP *bmp, const FONT *f, const char *s, int x1, x2, y, diff, color, bg);
Draws justified text within the region x1-x2. If the amount of spare space is greater than the diff value, it will give up and draw regular left justified text instead.

> See also: textout_ex, textprintf_justify_ex.

void textprintf_ex(BITMAP *bmp, const FONT *f, int x, y, color, bg, const char *fmt, ...);
Formatted text output, using a printf() style format string.

> See also: font, textout_ex, textprintf_centre_ex, textprintf_right_ex, textprintf_justify_ex, text_height, text_length.

void textprintf_centre_ex(BITMAP *bmp, const FONT *f, int x, y, color, bg, const char *fmt, ...);
Like textprintf_ex(), but interprets the x coordinate as the centre rather than the left edge of the string.

> See also: textprintf_ex, textout_centre_ex.

void textprintf_right_ex(BITMAP *bmp, const FONT *f, int x, y, color, bg, const char *fmt, ...);
Like textprintf_ex(), but interprets the x coordinate as the right rather than the left edge of the string.

> See also: textprintf_ex, textout_right_ex.

void textprintf_justify_ex(BITMAP *bmp, const FONT *f, int x1, x2, y, diff, color, bg, const char *fmt, ...);
Like textout_justify_ex(), but using a printf() style format string.

> See also: textprintf_ex, textout_justify_ex.

int text_mode(int mode);
Deprecated: if you use the new textout_ex() family, you no longer have to set the text mode.

Sets the mode in which text will be drawn. Returns previous mode. If mode is zero or positive, text output will be opaque and the background of the characters will be set to color 'mode'. If mode is negative, text will be drawn transparently (ie. the background of the characters will not be altered). The default is a mode of zero.

> See also: textout, textprintf.

void textout(BITMAP *bmp, const FONT *f, const char *s, int x, y, color);
Deprecated. Use textout_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: font, text_mode, textout_centre, textout_right, textout_justify, textprintf, text_height, text_length, textout_ex.

void textout_centre(BITMAP *bmp, const FONT *f, const char *s, int x, y, color);
Deprecated. Use textout_centre_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: textout, textprintf_centre, text_mode, textout_centre_ex.

void textout_right(BITMAP *bmp, const FONT *f, const char *s, int x, y, color);
Deprecated. Use textout_right_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: textout, textprintf_right, text_mode, textout_right_ex.

void textout_justify(BITMAP *bmp, const FONT *f, const char *s, int x1, x2, y, diff, color);
Deprecated. Use textout_justify_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: textout, textprintf_justify, text_mode, textout_justify_ex.

void textprintf(BITMAP *bmp, const FONT *f, int x, y, color, const char *fmt, ...);
Deprecated. Use textprintf_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: font, text_mode, textprintf_centre, text_mode, textprintf_right, textprintf_justify, textout, text_height, text_length, textprintf_ex.

void textprintf_centre(BITMAP *bmp, const FONT *f, int x, y, color, const char *fmt, ...);
Deprecated. Use textprintf_centre_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: textprintf, textout_centre, text_mode, textprintf_centre_ex.

void textprintf_right(BITMAP *bmp, const FONT *f, int x, y, color, const char *fmt, ...);
Deprecated. Use textprintf_right_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: textprintf, textout_right, text_mode, textprintf_right_ex.

void textprintf_justify(BITMAP *bmp, const FONT *f, int x1, x2, y, diff, color, const char *fmt, ...);
Deprecated. Use textprintf_justify_ex() instead, passing the mode you would have passed to text_mode() as the 'bg' parameter.

> See also: textprintf, textout_justify, text_mode, textprintf_justify_ex.

Back to contents