BFont.h 1.5 KB
Newer Older
1 2 3 4 5 6
/************************************************************/
/*                                                          */
/*   BFONT.h v. 1.0.3 - Billi Font Library by Diego Billi   */
/*                                                          */
/************************************************************/

7 8 9
#ifndef _BFont_h
#define _BFont_h

10
#include "system.h"
11
#include "struct.h"
12

13
#define FIRST_FONT_CHAR '!'
14 15 16 17 18 19 20 21 22 23 24 25
#define MAX_CHARS_IN_FONT 256

typedef struct BFont_Info {
	/* font height */
	int h;
	
	struct image font_image;
	struct image char_image[MAX_CHARS_IN_FONT];
	unsigned int number_of_chars;
} BFont_Info;

/* Load and store le font in the BFont_Info structure */
26
int load_bfont(const char *filepath, struct font *font);
27

28 29
/* Free all the allocated data stored in a BFont */
void free_bfont( struct font *font);
30 31

/* Returns the character width of the specified font */
32
int font_char_width(struct font *font, unsigned char c);
33

34 35
/* Write a single character on the screen with the specified font */
int put_char(struct font *font, int x, int y, unsigned char c);
36 37

/* Returns the width, in pixels, of the text calculated with the specified font*/
38
int text_width(struct font *font, const char *text);
39

40 41
/* Returns the index of the last character than is inside the width limit, with the specified font */
int limit_text_width(struct font *font, const char *text, int limit);
42

43 44
/* Write a string on the screen with the specified font */
void put_string(struct font *font, int x, int y, const char *text);
45

46
#endif // _BFont_h