1
This commit is contained in:
churl
2022-06-19 13:23:54 +02:00
parent eccc31545e
commit a18636ce87
2 changed files with 22 additions and 27 deletions

View File

@ -11,9 +11,9 @@
#include "devices/fonts/Font_sun_12x22.h"
#include "devices/fonts/Font_sun_8x16.h"
Font_8x16 std_font_8x16;
Font_8x8 std_font_8x8;
Font_acorn_8x8 acorn_font_8x8;
Font_pearl_8x8 pearl_font_8x8;
Font_sun_12x22 sun_font_12x22;
Font_sun_8x16 sun_font_8x16;
Font_8x16 std_font_8x16;
Font_8x8 std_font_8x8;
Font_acorn_8x8 acorn_font_8x8;
Font_pearl_8x8 pearl_font_8x8;
Font_sun_12x22 sun_font_12x22;
Font_sun_8x16 sun_font_8x16;

View File

@ -11,25 +11,22 @@
#ifndef __FONTS_H__
#define __FONTS_H__
class Font
{
class Font {
public:
virtual unsigned char* getChar(int c) const = 0;
virtual unsigned int get_char_width() const = 0;
virtual unsigned int get_char_height() const = 0;
};
template<unsigned int width, unsigned int height, unsigned char* data>
class FontInstance : public Font
{
class FontInstance : public Font {
const unsigned int char_width;
const unsigned int char_height;
const unsigned int char_mem_size;
unsigned char* font_data;
public:
FontInstance() : char_width(width), char_height(height), char_mem_size((((char_width + (8 >> 1)) / 8) * char_height)), font_data(data) { }
FontInstance() : char_width(width), char_height(height), char_mem_size((((char_width + (8 >> 1)) / 8) * char_height)), font_data(data) {}
inline unsigned char* getChar(int c) const {
return &font_data[char_mem_size * c];
}
@ -41,7 +38,6 @@ public:
}
};
extern unsigned char fontdata_8x16[];
extern unsigned char fontdata_8x8[];
extern unsigned char acorndata_8x8[];
@ -49,19 +45,18 @@ extern unsigned char fontdata_pearl_8x8[];
extern unsigned char fontdata_sun_12x22[];
extern unsigned char fontdata_sun_8x16[];
typedef FontInstance<8, 16, fontdata_8x16> Font_8x16;
typedef FontInstance<8, 8, fontdata_8x8> Font_8x8;
typedef FontInstance<8, 8, acorndata_8x8> Font_acorn_8x8;
typedef FontInstance<8, 8, fontdata_pearl_8x8> Font_pearl_8x8;
typedef FontInstance<12, 22, fontdata_sun_12x22> Font_sun_12x22;
typedef FontInstance<8, 16, fontdata_sun_8x16> Font_sun_8x16;
typedef FontInstance<8,16,fontdata_8x16> Font_8x16;
typedef FontInstance<8,8,fontdata_8x8> Font_8x8;
typedef FontInstance<8,8,acorndata_8x8> Font_acorn_8x8;
typedef FontInstance<8,8,fontdata_pearl_8x8> Font_pearl_8x8;
typedef FontInstance<12,22,fontdata_sun_12x22> Font_sun_12x22;
typedef FontInstance<8,16,fontdata_sun_8x16> Font_sun_8x16;
extern Font_8x16 std_font_8x16;
extern Font_8x8 std_font_8x8;
extern Font_acorn_8x8 acorn_font_8x8;
extern Font_pearl_8x8 pearl_font_8x8;
extern Font_sun_12x22 sun_font_12x22;
extern Font_sun_8x16 sun_font_8x16;
extern Font_8x16 std_font_8x16;
extern Font_8x8 std_font_8x8;
extern Font_acorn_8x8 acorn_font_8x8;
extern Font_pearl_8x8 pearl_font_8x8;
extern Font_sun_12x22 sun_font_12x22;
extern Font_sun_8x16 sun_font_8x16;
#endif