-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont.h
41 lines (32 loc) · 1.3 KB
/
font.h
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
/*
font.h
Header for the Cone3D SDL font routines.
Made by Marius Andra 2002
http://cone3d.gamedev.net
You can use the code for anything you like.
Even in a commercial project.
But please let me know where it ends up.
I'm just curious. That's all.
*/
#include <SDL/SDL.h> // just in case...
// Structure to hold our font
struct SDLFont
{
SDL_Surface *font; // The SDL Surface for the font image
int width; // Width of the SDL Surface (same as the height)
int charWidth; // Width of one block character in the font (fontWidth/16)
int *widths; // Real widths of all the fonts
unsigned char *data; // The raw font data
};
// Function prototypes
// This function initalizes a font
SDLFont *initFont(char *fontdir, float r, float g, float b, float a);
// Some overloaded functions to make your life easier
inline SDLFont *initFont(char *fontdir, float r, float g, float b) { return initFont(fontdir, r,g,b,1); }
inline SDLFont *initFont(char *fontdir) { return initFont(fontdir, 1,1,1,1); }
// This function draws a string
void drawString(SDL_Surface *screen, SDLFont *font, int x, int y, char *str,...);
// This function returns the width of a string
int stringWidth(SDLFont *font, char *str,...);
// This function destroys the font
void freeFont(SDLFont *font);