forked from ofZach/RTP_SFPC_SUMMER20
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFont.h
More file actions
30 lines (26 loc) · 647 Bytes
/
Font.h
File metadata and controls
30 lines (26 loc) · 647 Bytes
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
#pragma once
template<class Graphics>
class Font
{
public:
int xres;
int yres;
const unsigned char *pixels;
Font(int charWidth, int charHeight, const unsigned char *pixels_)
:xres(charWidth),
yres(charHeight),
pixels(pixels_)
{
}
void drawChar(Graphics &g, int x, int y, char ch, int frontColor, int backColor)
{
const unsigned char *pix = &pixels[xres * yres * (ch - 32)];
for(int py = 0; py < yres; py++)
for(int px = 0; px < xres; px++)
if(*(pix++))
g.dot(px + x, py + y, frontColor);
else
if(backColor >= 0)
g.dot(px + x, py + y, backColor);
}
};