make fonts more generic
This commit is contained in:
parent
1009d689bc
commit
58f3d1f02b
9 changed files with 235 additions and 183 deletions
189
src/gfx/font.cpp
189
src/gfx/font.cpp
|
|
@ -3,168 +3,29 @@
|
|||
//
|
||||
|
||||
#include "gfx/font.h"
|
||||
#include "gfx/canvas.h"
|
||||
|
||||
bool testFont[32][20] = {
|
||||
//0
|
||||
{0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0},
|
||||
//A
|
||||
{0,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,1,1,1,
|
||||
1,0,0,1},
|
||||
//B
|
||||
{1,1,1,0,
|
||||
1,0,0,1,
|
||||
1,1,1,0,
|
||||
1,0,0,1,
|
||||
1,1,1,0},
|
||||
//C
|
||||
{0,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,0,
|
||||
1,0,0,1,
|
||||
0,1,1,0},
|
||||
//D
|
||||
{1,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,1,1,0},
|
||||
//E
|
||||
{1,1,1,1,
|
||||
1,0,0,0,
|
||||
1,1,1,0,
|
||||
1,0,0,0,
|
||||
1,1,1,1},
|
||||
//F
|
||||
{1,1,1,1,
|
||||
1,0,0,0,
|
||||
1,1,1,0,
|
||||
1,0,0,0,
|
||||
1,0,0,0},
|
||||
//G
|
||||
{0,1,1,1,
|
||||
1,0,0,0,
|
||||
1,0,1,1,
|
||||
1,0,0,1,
|
||||
0,1,1,1},
|
||||
//H
|
||||
{1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,1,1,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1},
|
||||
//I
|
||||
{1,1,1,0,
|
||||
0,1,0,0,
|
||||
0,1,0,0,
|
||||
0,1,0,0,
|
||||
1,1,1,0},
|
||||
//J
|
||||
{1,1,1,1,
|
||||
0,0,0,1,
|
||||
0,0,0,1,
|
||||
0,0,0,1,
|
||||
1,1,1,0},
|
||||
//K
|
||||
{1,0,0,1,
|
||||
1,0,1,0,
|
||||
1,1,0,0,
|
||||
1,0,1,0,
|
||||
1,0,0,1},
|
||||
//L
|
||||
{1,0,0,0,
|
||||
1,0,0,0,
|
||||
1,0,0,0,
|
||||
1,0,0,0,
|
||||
1,1,1,1},
|
||||
//M
|
||||
{1,0,0,1,
|
||||
1,1,1,1,
|
||||
1,1,1,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1},
|
||||
//N
|
||||
{1,0,0,1,
|
||||
1,1,0,1,
|
||||
1,0,1,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1},
|
||||
//O
|
||||
{0,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
0,1,1,0},
|
||||
//P
|
||||
{1,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,1,1,0,
|
||||
1,0,0,0},
|
||||
//Q
|
||||
{0,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,0,1,1,
|
||||
0,1,1,1},
|
||||
//R
|
||||
{1,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,1,1,0,
|
||||
1,0,0,1},
|
||||
//S
|
||||
{0,1,1,1,
|
||||
1,0,0,0,
|
||||
0,1,1,0,
|
||||
0,0,0,1,
|
||||
1,1,1,0},
|
||||
//T
|
||||
{1,1,1,1,
|
||||
0,0,1,0,
|
||||
0,0,1,0,
|
||||
0,0,1,0,
|
||||
0,0,1,0},
|
||||
//U
|
||||
{1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,0,0,1,
|
||||
0,1,1,0},
|
||||
//V
|
||||
{1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,0,1,0,
|
||||
1,0,1,0,
|
||||
0,1,0,0},
|
||||
//W
|
||||
{1,0,0,1,
|
||||
1,0,0,1,
|
||||
1,1,1,1,
|
||||
1,1,1,1,
|
||||
0,1,1,0},
|
||||
//X
|
||||
{1,0,0,1,
|
||||
1,0,0,1,
|
||||
0,1,1,0,
|
||||
1,0,0,1,
|
||||
1,0,0,1},
|
||||
//Y
|
||||
{1,0,0,1,
|
||||
1,0,0,1,
|
||||
0,1,1,1,
|
||||
0,0,0,1,
|
||||
1,1,1,0},
|
||||
//Z
|
||||
{1,1,1,1,
|
||||
0,0,0,1,
|
||||
0,1,1,0,
|
||||
1,0,0,0,
|
||||
1,1,1,1},
|
||||
};
|
||||
|
||||
|
||||
font::font(raw_font& raw ):raw_data_(raw){
|
||||
}
|
||||
|
||||
void font::print(int x, int y, char l, canvas& c) {
|
||||
int j = (l - ' ') % 32;
|
||||
for (int x_ = 0; x_ < 4; x_++)
|
||||
for (int y_ = 0; y_ < 5; y_++)
|
||||
if (raw_data_[j][x_ + 4 * y_])
|
||||
c.draw(x + x_, y + y_);
|
||||
}
|
||||
|
||||
void font::print(int x, int y, char* str, canvas& c) {
|
||||
for (int i = 0; str[i]; i++) {
|
||||
print(x + i * 5,y,str[i],c);
|
||||
}
|
||||
}
|
||||
|
||||
void font::print(int x, int y, const char* str, canvas& c) {
|
||||
for (int i = 0; str[i]; i++) {
|
||||
print(x + i * 5,y,str[i],c);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue