143 lines
5.4 KiB
C++
143 lines
5.4 KiB
C++
//
|
|
//
|
|
//
|
|
|
|
#include "font.h"
|
|
|
|
static uint8_t characters[] = {
|
|
0x3A,0x5A,0x0A,0xCA, //!
|
|
0x31,0x7A,0x32,0xFB, //"
|
|
0x39,0x49,0x0B,0x7B,0x2C,0x68,0x18,0xDC, //#
|
|
0x10,0x53,0x5C,0x63,0x61,0x68,0x71,0x74,0x3A,0xCA, // $
|
|
0x7C,0x39,0x70,0x69,0x72,0x79,0x1B,0x52,0x4B,0x54,0xDB, //%
|
|
0x0C,0x68,0x70,0x79,0x7A,0x73,0x6B,0x50,0x49,0x4A,0xDC, //&
|
|
0x3B,0xF2, //'
|
|
0x3B,0x69,0x59,0xCB,// (
|
|
0x39,0x6B,0x5B,0xC9, // )
|
|
0x11,0x73,0x24,0x60,0x31,0xD3, //*
|
|
0x20,0x64,0x32,0xD2, //+
|
|
0x12,0xC1, //,
|
|
0x20,0xE4, //-
|
|
0x0A,0xCA, // .
|
|
0xFC, // /
|
|
0x7C,0x34,0x54,0x4B,0x49,0x50,0x70,0x79,0x7B,0xF4, //0
|
|
0x29,0x7B,0xCB,
|
|
0x30,0x79,0x7B,0x74,0x6C,0x48,0xCC,
|
|
0x30,0x79,0x7B,0x74,0x6C,0x63,0x5C,0x54,0x4B,0x49,0xD0,
|
|
0x0B,0x7B,0x58,0xDC,
|
|
0x10,0x49,0x4B,0x54,0x5C,0x63,0x60,0x78,0xFC,
|
|
0x34,0x7B,0x79,0x70,0x50,0x49,0x4B,0x54,0x5C,0x63,0x61,0xD8,
|
|
0x7C,0xF8,
|
|
0x09,0x50,0x58,0x61,0x63,0x6C,0x74,0x7B,0x79,0x70,0x68,0x61,0x63,0x5C,0x54,0x4B,0xC9,
|
|
0x10,0x49,0x4B,0x54,0x74,0x7B,0x79,0x70,0x68,0x61,0x63,0xEC, //9
|
|
0x1A,0x5A,0x2A,0xEA, //:
|
|
0x01,0x52,0x22,0xE2,0x33,0x61,0xD3, //;
|
|
0x28,0x6C,0x18,0xDC, //<
|
|
0x31,0x63,0xD1, //=
|
|
0x30,0x79,0x7B,0x74,0x6C,0x5A,0x52,0x0A,0xCA, //>
|
|
0x68,0x71,0x73,0x6C,0x54,0x4B,0x4A,0x51,0x61,0x6A,0x63,0xCB, // ?
|
|
0x7A,0x4C,0x21,0xE3, // @
|
|
0x78,0x7B,0x74,0x6C,0x63,0x60,0x63,0x5C,0x54,0x4B,0xC8, //A
|
|
0x34,0x7B,0x79,0x70,0x50,0x49,0x4B,0xD4,
|
|
0x78,0x7B,0x74,0x54,0x4B,0xC8,
|
|
0x3C,0x78,0x48,0x4C,0x20,0xE2,
|
|
0x78,0x7C,0x20,0xE2,
|
|
0x34,0x7B,0x79,0x70,0x50,0x49,0x4B,0x54,0x5C,0xDA,
|
|
0x78,0x3C,0x4C,0x20,0xE4,
|
|
0x09,0x4B,0x4A,0x7A,0x79,0xFB,
|
|
0x10,0x49,0x4B,0x54,0xFC,
|
|
0x78,0x3C,0x60,0xCC,0x38,0x48,0xCC,0x78,0x62,0x7C,0xCC,0x78,0x4C,0xFC,0x09,0x50,0x70,
|
|
0x79,0x7B,0x74,0x54,0x4B,0xC9,0x78,0x7B,0x74,0x6C,0x63,0xE0,0x09,0x50,0x70,0x79,
|
|
0x7B,0x74,0x54,0x4B,0x49,0x1A,0xCC,0x78,0x7B,0x74,0x6C,0x63,0x60,0xCC,0x10,0x49,
|
|
0x4B,0x54,0x5C,0x63,0x61,0x68,0x70,0x79,0x7B,0xF4,0x38,0x7C,0x3A,0xCA,0x38,0x50,
|
|
0x49,0x4B,0x54,0xFC,0x38,0x4A,0xFC,0x38,0x49,0x6A,0x4B,0xFC,0x7C,0x38,0xCC,0x38,
|
|
0x62,0x7C,0x22,0xCA,0x38,0x7C,0x48,0xCC,0x3B,0x79,0x49,0xCB,0x38,0xCC,0x39,0x7B,
|
|
0x4B,0xC9,0x31,0x7A,0xF3,0x00,0xC4,0x39,0xF2,0x29,0x6B,0x64,0x54,0x4B,0x49,0x50,
|
|
0x59,0x5B,0x54,0xCC,0x78,0x28,0x6B,0x64,0x54,0x4B,0xC8,0x2C,0x69,0x60,0x50,0x49,
|
|
0xCC,0x3C,0x4C,0x49,0x50,0x60,0x69,0xEC,0x18,0x5C,0x64,0x6B,0x69,0x60,0x50,0x49,
|
|
0xCC,0x0A,0x72,0x7B,0x7C,0x21,0xE3,0x00,0x43,0x4C,0x6C,0x69,0x60,0x58,0x51,0xD4,
|
|
0x78,0x28,0x6B,0x64,0xCC,0x09,0x4B,0x4A,0x6A,0x69,0x3A,0xFA,0x01,0x42,0x4B,0x6B,
|
|
0x6A,0x3B,0xFB,0x78,0x2C,0x58,0xCC,0x09,0x4B,0x4A,0x7A,0xF9,0x68,0x60,0x69,0x62,
|
|
0x4A,0x22,0x6B,0x64,0xCC,0x68,0x60,0x69,0x6B,0x64,0xCC,0x09,0x50,0x60,0x69,0x6B,
|
|
0x64,0x54,0x4B,0xC9,0x00,0x68,0x6B,0x64,0x5C,0x53,0xD0,0x04,0x6C,0x69,0x60,0x58,
|
|
0x51,0xD4,0x09,0x69,0x61,0x6A,0x6B,0xE4,0x4B,0x54,0x5B,0x59,0x60,0x69,0xEC,0x0C,
|
|
0x4B,0x52,0x7A,0x29,0xEB,0x28,0x50,0x49,0x4B,0x54,0xEC,0x28,0x4A,0xEC,0x28,0x49,
|
|
0x62,0x4B,0xEC,0x6C,0x28,0xCC,0x00,0x43,0x4C,0x6C,0x28,0x58,0x51,0xD4,0x28,0x6C,
|
|
0x48,0xCC,0x0B,0x52,0x5A,0x61,0x6A,0x72,0xFB,0x0A,0xFA,0x09,0x52,0x5A,0x63,0x6A,
|
|
0x72,0xF9,0x20,0x69,0x5B,0xE4,0x80,0x32,0xFB,0x2A,0x71,0x7A,0x73,0xEA,0x39,0x72,
|
|
0xFB,0x31,0x7A,0xF3,0x39,0x79,0x3B,0xFB
|
|
};
|
|
|
|
|
|
bool isFontCharEnd(uint8_t b)
|
|
{
|
|
return b & 0x80;
|
|
};
|
|
|
|
int getFontCharOffset(char ch)
|
|
{
|
|
char actual = '!';
|
|
for (int i = 0; i < sizeof(characters); i++)
|
|
{
|
|
if (actual == ch)
|
|
return i;
|
|
if (isFontCharEnd(characters[i]))
|
|
{
|
|
actual++;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
|
|
void drawFontString(Plotter *plotter, String s, int scale)
|
|
{
|
|
|
|
bool penUp = true;
|
|
plotter->pu();
|
|
for (int i = 0; i < s.length(); i++)
|
|
{
|
|
char ch = s[i];
|
|
//LOG(String("character:")+ch);
|
|
Point savedpos = plotter->getCurrentPos();
|
|
savedpos.y += scale;
|
|
if (ch < ' ' || ch > '\x7f')
|
|
{
|
|
continue;
|
|
}
|
|
if (ch != ' ')
|
|
{
|
|
int pos = getFontCharOffset(ch);
|
|
do
|
|
{
|
|
uint8_t instr = characters[pos] & 0x7f;
|
|
if ((instr & 0x40) > 0)
|
|
{
|
|
if (penUp)
|
|
{
|
|
plotter->pd();
|
|
}
|
|
penUp = false;
|
|
}
|
|
else
|
|
{
|
|
if (!penUp)
|
|
{
|
|
plotter->pu();
|
|
}
|
|
penUp = true;
|
|
}
|
|
int nx = instr & 0x7;
|
|
int ny = (instr & 0x38) >> 3; //absolutni pozice od 0,0
|
|
nx*=scale;
|
|
ny*=scale;
|
|
plotter->moveto(savedpos.x + nx, savedpos.y + ny);
|
|
} while(!isFontCharEnd(characters[pos++]));
|
|
}
|
|
//move
|
|
penUp = true;
|
|
plotter->pu();
|
|
plotter->moveto((6 * scale) + savedpos.x, savedpos.y - scale);
|
|
}
|
|
};
|
|
|