Permalink
Browse files

Add blocks/gaps to the font format

  • Loading branch information...
mniip committed May 1, 2018
1 parent 9d927cb commit b8c5e94a41a21d6d6a801aca3ba049423f4addfb
Showing with 265 additions and 112 deletions.
  1. +13 −3 data/font.h
  2. +17 −1 src/graphics/Font.h
  3. +219 −97 src/gui/font/FontEditor.cpp
  4. +16 −11 src/gui/font/FontEditor.h
@@ -260,9 +260,10 @@ unsigned char font_data[] = {
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x0A, 0x00, 0x00, 0x00, 0x74, 0x00, 0xD0, 0x1F, 0x40, 0x8B, 0x07, 0x3D, 0xF3, 0xF1, 0x3F, 0x3F, 0xFD, 0xF8, 0x41, 0xFF, 0x07, 0xD0, 0x1C, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
short font_ptrs[] = {
unsigned short font_ptrs[] = {
0x0000, 0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070,
0x0080, 0x0090, 0x00A0, 0x00B0, 0x00C0, 0x00D0, 0x00E0, 0x00F0,
0x0100, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160, 0x0170,
@@ -295,14 +296,23 @@ short font_ptrs[] = {
0x1396, 0x13A9, 0x13BC, 0x13CF, 0x13E2, 0x13F5, 0x1408, 0x141B,
0x142E, 0x1441, 0x1454, 0x1467, 0x147A, 0x148D, 0x14A0, 0x14B3,
0x14C6, 0x14D9, 0x14EC, 0x14FF, 0x1512, 0x1525, 0x1538, 0x154B,
0x155E,
};
unsigned int font_ranges[][2] = {
{ 0x000000, 0x0000FF },
{ 0x00FFFD, 0x00FFFD },
{ 0, 0 },
};
#else
extern unsigned char font_data[];
extern short font_ptrs[];
extern unsigned short font_ptrs[];
extern unsigned int font_ranges[][2];
#endif
#else
extern unsigned char *font_data;
extern short *font_ptrs;
extern unsigned short *font_ptrs;
extern unsigned int (*font_ranges)[2];
#endif
#endif
@@ -17,9 +17,25 @@ class FontReader
data(0)
{}
static inline unsigned char *lookupChar(String::value_type ch)
{
size_t offset = 0;
for(int i = 0; font_ranges[i][1]; i++)
if(font_ranges[i][0] > ch)
break;
else if(font_ranges[i][1] >= ch)
return &font_data[font_ptrs[offset + (ch - font_ranges[i][0])]];
else
offset += font_ranges[i][1] - font_ranges[i][0] + 1;
if(ch == 0xFFFD)
return &font_data[0];
else
return lookupChar(0xFFFD);
}
public:
inline FontReader(String::value_type ch):
FontReader(ch <= 0xFF ? &font_data[font_ptrs[ch]] : &font_data[0])
FontReader(lookupChar(ch))
{
}
Oops, something went wrong.

0 comments on commit b8c5e94

Please sign in to comment.