summaryrefslogtreecommitdiff
path: root/i/serialplot/BFont.h
blob: bf0875b6d8af71698cfd58efa8bf41c022b29c1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/************************************************************/
/*                                                          */
/*   BFONT.h v. 1.1.0 - Billi Font Library by Diego Billi   */
/*                                                          */
/*   mail: dbilli@cs.unibo.it                               */
/*   home: http://www.cs.unibo.it/~dbilli (ITALIAN)         */
/*                                                          */
/************************************************************/


#ifndef __BFONT_H_
#define __BFONT_H_


#include "SDL.h"

#ifdef __cplusplus
extern "C" {
#endif


/* Max number of characters allowed in a BFont font */
#define BFONT_NUM_CHARS 256


/* BFont font structure */
typedef struct _BFont_Info BFont_Info;


/* Load and store the font in the BFont_Info structure */
BFont_Info * BFont_LoadFont (const char *filename);

/* Free memory */
void BFont_FreeFont(BFont_Info *Font);

/* Returns a pointer to the current font structure */
BFont_Info * BFont_GetCurrentFont(void);

/* Set the current font */
void BFont_SetCurrentFont (BFont_Info *Font);

/* Returns the font height */
int BFont_FontHeight (BFont_Info *Font);

/* Change the font height */
void BFont_SetFontHeight (BFont_Info *Font, int height);

/* Returns the character width of the specified font */
int BFont_CharWidth (BFont_Info *Font,int c);

/* Write a single character on the "Surface" with the current font */
int BFont_PutChar (SDL_Surface *Surface, int x, int y, int c);

/* Write a single character on the "Surface" with the specified font */
int BFont_PutCharFont (SDL_Surface *Surface, BFont_Info *Font,int x, int y, int c);

/* Returns the width, in pixels, of the text calculated with the current font*/
int BFont_TextWidth (const char *text);

/* Returns the width, in pixels, of the text calculated with the specified font*/
int BFont_TextWidthFont (BFont_Info *Font, const char *text);

/* Write a string on the "Surface" with the current font */
void BFont_PutString (SDL_Surface *Surface, int x, int y, const char *text);

/* Write a string on the "Surface" with the specified font */
void BFont_PutStringFont (SDL_Surface *Surface, BFont_Info *Font, int x, int y, const char *text);

/* Write a left-aligned string on the "Surface" with the current font */
void BFont_LeftPutString (SDL_Surface *Surface, int y, const char *text);

/* Write a left-aligned string on the "Surface" with the specified font */
void BFont_LeftPutStringFont (SDL_Surface *Surface, BFont_Info *Font, int y, const char *text);

/* Write a center-aligned string on the "Surface" with the current font */
void BFont_CenteredPutString (SDL_Surface *Surface, int y, const char *text);

/* Write a center-aligned string on the "Surface" with the specified font */
void BFont_CenteredPutStringFont (SDL_Surface *Surface, BFont_Info *Font, int y, const char *text);

/* Write a right-aligned string on the "Surface" with the specified font */
void BFont_RightPutString (SDL_Surface *Surface, int y, const char *text);

/* Write a right-aligned string on the "Surface" with the specified font */
void BFont_RightPutStringFont (SDL_Surface *Surface, BFont_Info *Font, int y, const char *text);

/* Write a justify-aligned string on the "Surface" with the specified font */
void BFont_JustifiedPutString (SDL_Surface *Surface, int y, const char *text);

/* Write a justify-aligned string on the "Surface" with the specified font */
void BFont_JustifiedPutStringFont (SDL_Surface *Surface, BFont_Info *Font, int y, const char *text);


/* The following functions do the same task but have the classic "printf" sintax */

void BFont_PrintString              (SDL_Surface *Surface, int x, int y, const char *fmt, ...);
void BFont_PrintStringFont          (SDL_Surface *Surface, BFont_Info *Font, int x, int y, const char *fmt, ...);

void BFont_CenteredPrintString      (SDL_Surface *Surface, int y,  const char *fmt, ...);
void BFont_CenteredPrintStringFont  (SDL_Surface *Surface, BFont_Info *Font, int y,  const char *fmt, ...);

void BFont_RightPrintString         (SDL_Surface *Surface, int y, const char *fmt, ...);
void BFont_RightPrintStringFont     (SDL_Surface *Surface, BFont_Info *Font, int y,  const char *fmt, ...);

void BFont_LeftPrintString          (SDL_Surface *Surface, int y, const char *fmt, ...);
void BFont_LeftPrintStringFont      (SDL_Surface *Surface, BFont_Info *Font, int y,  const char *fmt, ...);

void BFont_JustifiedPrintString     (SDL_Surface *Surface, int y, const char *fmt, ...);
void BFont_JustifiedPrintStringFont (SDL_Surface *Surface, BFont_Info *Font,  int y, const char *fmt, ...);


/* Returns a new font colored with the color (r,g,b) */
BFont_Info * BFont_SetFontColor (BFont_Info *Font,Uint8 r, Uint8 g, Uint8 b);


/* Load and store the font int the BFont_Info structure from a SDL surface */
BFont_Info * BFont_LoadFontFromSurface (SDL_Surface *Surface);


/* Return a SDL Surface containing the string "text" */
SDL_Surface * BFont_CreateSurface (const char *text);
SDL_Surface * BFont_CreateSurfaceFont (BFont_Info *Font, const char *text);


/* This is for compatibility with old versions 1.0.X */

#ifdef BFONT_KEEP_COMPATIBILITY

	/* BFont v. 1.0.2 */

	#define LoadFont                 BFont_LoadFont
	#define FreeFont                 BFont_FreeFont
	#define GetCurrentFont           BFont_GetCurrentFont
	#define SetCurrentFont           BFont_SetCurrentFont
	#define FontHeight               BFont_FontHeight
	#define SetFontHeight            BFont_SetFontHeight
	#define CharWidth                BFont_CharWidth
	#define PutChar                  BFont_PutChar
	#define PutCharFont              BFont_PutCharFont
	#define TextWidth                BFont_TextWidth
	#define TextWidthFont            BFont_TextWidthFont
	#define PutString                BFont_PutString 
	#define PutStringFont            BFont_PutStringFont
	#define LeftPutString            BFont_LeftPutString
	#define LeftPutStringFont        BFont_LeftPutStringFont
	#define CenteredPutString        BFont_CenteredPutString
	#define CenteredPutStringFont    BFont_CenteredPutStringFont
	#define RightPutString           BFont_RightPutString 
	#define RightPutStringFont       BFont_RightPutStringFont
	#define JustifiedPutString       BFont_JustifiedPutString
	#define JustifiedPutStringFont   BFont_JustifiedPutStringFont

	#define PrintString              BFont_PrintString 
	#define PrintStringFont          BFont_PrintStringFont
	#define CenteredPrintString      BFont_CenteredPrintString 
	#define CenteredPrintStringFont  BFont_CenteredPrintStringFont  
	#define RightPrintString         BFont_RightPrintString
	#define RightPrintStringFont     BFont_RightPrintStringFont
	#define LeftPrintString          BFont_LeftPrintString
	#define LeftPrintStringFont      BFont_LeftPrintStringFont
	#define JustifiedPrintString     BFont_JustifiedPrintString
	#define JustifiedPrintStringFont BFont_JustifiedPrintStringFont

	/* BFont v. 1.0.3 */

	#define SetFontColor             BFont_SetFontColor

	/* BFont v. 1.0.4 */

	#define LoadFontFromSurface      BFont_LoadFontFromSurface

	/* BFont v. 1.0.5 */

	#define CreateSurface            BFont_CreateSurface
	#define CreateSurfaceFont        BFont_CreateSurfaceFont

#endif /* end compatibility */



#ifdef __cplusplus
}
#endif

#endif