There is a known common approach to store the fonts definition as per:
char fontImg[][FONTW * FONTH] = {
{ // ' ' (space)
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
},
Is there any better/more c++ approach to do this? I hate mixing C / C++ code and i avoid it wherever possible, so instead of working with an array, does anybody know what else could be used to store a definition of fonts ?
std::vector
std::map
anything else?
A quick idea:
// Change to class later
struct tCharacter
{
uint8_t m_uiSizeX;
uint8_t m_uiSizeY;
std::string m_strData;
};
std::map<uint8_t,tCharacter> m_mFonts;
tCharacter _Char;
// 0 empty pixel, 1 filled pixel, # 'return carret'
/*
00111100#
01000010#
01000010#
01000010#
01111110#
01000010#
01000010#
01000010
*/
_Char.m_strData="00111100#01000010#01000010#01000010#01111110#01000010#01000010#01000010";
m_mFonts['a']=_Char;