make fonts more generic
This commit is contained in:
parent
1009d689bc
commit
58f3d1f02b
9 changed files with 235 additions and 183 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "hal.h"
|
||||
#include "gfx/font.h"
|
||||
#include "fonts/basic_5x4.h"
|
||||
|
||||
class canvas {
|
||||
private:
|
||||
|
|
@ -23,23 +24,11 @@ public:
|
|||
}
|
||||
|
||||
void print(int x, int y, const char *str) {
|
||||
for (int i = 0; str[i]; i++) {
|
||||
int j = (str[i] - ' ') % 32;
|
||||
for (int x_ = 0; x_ < 4; x_++)
|
||||
for (int y_ = 0; y_ < 5; y_++)
|
||||
if (testFont[j][x_ + 4 * y_])
|
||||
draw(x + i * 5 + x_, y + y_);
|
||||
}
|
||||
basic_5x4.print(x, y, str, *this);
|
||||
}
|
||||
|
||||
void print(int x, int y, char *str) {
|
||||
for (int i = 0; str[i]; i++) {
|
||||
int j = (str[i] - ' ') % 32;
|
||||
for (int x_ = 0; x_ < 4; x_++)
|
||||
for (int y_ = 0; y_ < 5; y_++)
|
||||
if (testFont[j][x_ + 4 * y_])
|
||||
draw(x + i * 5 + x_, y + y_);
|
||||
}
|
||||
basic_5x4.print(x, y, str, *this);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,12 +5,18 @@
|
|||
#ifndef MGL_DMXMENU_FONT_H
|
||||
#define MGL_DMXMENU_FONT_H
|
||||
|
||||
|
||||
class canvas;
|
||||
|
||||
class font {
|
||||
|
||||
public:
|
||||
typedef const bool raw_font[32][20];
|
||||
private:
|
||||
raw_font& raw_data_;
|
||||
public:
|
||||
font(raw_font&);
|
||||
void print(int x, int y, char c, canvas&);
|
||||
void print(int x, int y, char* str, canvas&);
|
||||
void print(int x, int y, const char* str, canvas&);
|
||||
};
|
||||
|
||||
extern bool testFont[32][20];
|
||||
|
||||
#endif //MGL_DMXMENU_FONT_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue