loboris / ESP32_TFT_library

Full featured TFT library for ESP32 with demo application
553 stars 219 forks source link

Fonts with UTF8 characters support #63

Open MichaelVLV opened 5 years ago

MichaelVLV commented 5 years ago

I'm interested in using special language characters in drawing texts.

After I have prepared .c file from .ttf font with this tool https://github.com/loboris/ESP32_TFT_library/tree/master/tools I got array without special characters. I have tried change ranges with command _./ttf2cvc2003.exe 18 CODE2000.TTF code2000.c 190 512

but looks like there is a limit with 256 characters...

Generated file:

uint8_t code200018[] PROGMEM = 
{
0x00, 0x12, 0x00, 0x00,

// Individual Character Format:
// ----------------------------
// Character Code
// Adjusted Y Offset
// Width
// Height
// xOffset
// xDelta (the distance to move the cursor. Effective width of the character.)
// Data[n]

// NOTE: You can remove any of these characters if they are not needed in
// your application. The first character number in each Glyph indicates
// the ASCII character code. Therefore, these do not have to be sequential.
// Just remove all the content for a particular character to save space.

// 'ާ
0xBE,0x03,0x0E,0x12,0x01,0x0F,
0x38,0x01,0x30,0x40,0xC1,0x06,0x0C,0x08,0x20,0x31,0x84,0xC4,0x0E,0x30,0x01,0x80,0x04,0x00,0x31,0x00,0x8C,0x06,0x30,0x12,0xC0,0xDF,0x82,0x0C,0x18,0x30,0x01,0xC0,
// 'ߧ
0xBF,0x06,0x07,0x0D,0x01,0x09,
0x10,0x20,0x00,0x81,0x83,0x06,0x30,0xC1,0x87,0x0E,0x37,0xC0,
// ''
0xC0,0x01,0x0D,0x11,0x00,0x0E,
0x08,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x60,0x07,0x00,0x2C,0x02,0x20,0x11,0x80,0xFC,0x08,0x20,0x41,0x84,0x04,0x70,0x78,
// 'g
0xC1,0x01,0x0D,0x11,0x00,0x0E,
0x00,0x80,0x04,0x00,0x40,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x60,0x07,0x00,0x2C,0x02,0x20,0x11,0x80,0xFC,0x08,0x20,0x41,0x84,0x04,0x70,0x78,
// '§
0xC2,0x01,0x0D,0x11,0x00,0x0E,
0x00,0x00,0x10,0x01,0x40,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x60,0x07,0x00,0x2C,0x02,0x20,0x11,0x80,0xFC,0x08,0x20,0x41,0x84,0x04,0x70,0x78,
// 'ç
0xC3,0x02,0x0D,0x10,0x00,0x0E,
0x0E,0x00,0x0C,0x00,0x00,0x00,0x00,0x20,0x01,0x00,0x0C,0x00,0xE0,0x05,0x80,0x44,0x02,0x30,0x1F,0x81,0x04,0x08,0x30,0x80,0x8E,0x0F,
// 'ħ
0xC4,0x03,0x0D,0x0F,0x00,0x0D,
0x0C,0x80,0x44,0x00,0x00,0x04,0x00,0x20,0x03,0x80,0x1C,0x00,0xA0,0x09,0x80,0x44,0x03,0xF0,0x20,0x81,0x06,0x10,0x31,0xC1,0xC0,
// 'ŧ
0xC5,0x00,0x0D,0x12,0x00,0x0E,
0x00,0x00,0x38,0x00,0x00,0x08,0x00,0x20,0x00,0x00,0x08,0x00,0x40,0x03,0x00,0x38,0x01,0x60,0x11,0x00,0x8C,0x07,0xE0,0x41,0x02,0x0C,0x20,0x23,0x83,0xC0,
// 'Ƨ
0xC6,0x06,0x10,0x0C,0x00,0x10,
0x01,0xFF,0x01,0xC1,0x02,0xC0,0x02,0xC0,0x04,0xC0,0x04,0xFE,0x0F,0xC2,0x18,0xC0,0x10,0xC0,0x30,0xC0,0x20,0xC1,0x61,0xFF,
// 'ǧ
0xC7,0x06,0x0B,0x11,0x01,0x0C,
0x1F,0x06,0x19,0x81,0x60,0x2C,0x01,0x80,0x30,0x06,0x00,0xC0,0x0C,0x09,0xC3,0x0F,0x80,0x40,0x08,0x00,0xC0,0x18,0x1E,0x00,
// 'ȧ
0xC8,0x01,0x0A,0x11,0x00,0x0A,
0x10,0x06,0x00,0x80,0x10,0x00,0x1F,0xF3,0x04,0xC0,0x30,0x0C,0x03,0xF8,0xC2,0x30,0x0C,0x03,0x00,0xC1,0x7F,0xC0,
// 'ɧ
0xC9,0x01,0x0A,0x11,0x00,0x0A,
0x01,0x00,0xC0,0x20,0x00,0x00,0x1F,0xF3,0x04,0xC0,0x30,0x0C,0x03,0xF8,0xC2,0x30,0x0C,0x03,0x00,0xC1,0x7F,0xC0,
// 'ʧ
0xCA,0x01,0x0A,0x11,0x00,0x0A,
0x00,0x03,0x01,0xA0,0x00,0x00,0x1F,0xF3,0x04,0xC0,0x30,0x0C,0x03,0xF8,0xC2,0x30,0x0C,0x03,0x00,0xC1,0x7F,0xC0,
// '˧
0xCB,0x03,0x0A,0x0F,0x00,0x0A,
0x12,0x04,0x80,0x01,0xFF,0x30,0x4C,0x03,0x00,0xC2,0x3F,0x8C,0x63,0x08,0xC0,0x30,0x0C,0x17,0xFC,
// '̧
0xCC,0x01,0x06,0x11,0x00,0x06,
0xC1,0x06,0x08,0x01,0xE3,0x0C,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x78,
// 'ͧ
0xCD,0x01,0x06,0x11,0x00,0x06,
0x08,0x21,0x00,0x01,0xE3,0x0C,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x78,
// 'Χ
0xCE,0x01,0x07,0x11,0xFF,0x06,
0x00,0x30,0xB0,0x00,0x07,0x86,0x0C,0x18,0x30,0x60,0xC1,0x83,0x06,0x0C,0x3C,
// 'ϧ
0xCF,0x03,0x06,0x0F,0x01,0x07,
0x8A,0x20,0x1E,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x30,0xC7,0x80,
// 'Ч
0xD0,0x06,0x0C,0x0C,0x00,0x0C,
0x3F,0x81,0x8C,0x18,0x61,0x82,0x18,0x37,0xE3,0x1A,0x31,0x83,0x18,0x21,0x86,0x18,0xC3,0xF8,
// 'ѧ
0xD1,0x02,0x0E,0x10,0x00,0x0E,
0x0E,0x00,0x07,0x00,0x00,0x00,0x00,0x78,0x78,0xE0,0xC3,0xC3,0x0D,0x0C,0x36,0x30,0xC8,0xC3,0x33,0x0C,0x4C,0x31,0xB0,0xC2,0xC3,0x07,0x1E,0x1E,
// 'ҧ
0xD2,0x01,0x0B,0x11,0x01,0x0D,
0x10,0x03,0x00,0x20,0x00,0x00,0x00,0x3E,0x0C,0x63,0x06,0xC0,0x78,0x0F,0x01,0xE0,0x3C,0x07,0x80,0xD8,0x31,0x8C,0x1F,0x00,
// 'ӧ
0xD3,0x01,0x0B,0x11,0x01,0x0D,
0x01,0x00,0x60,0x08,0x00,0x00,0x00,0x3E,0x0C,0x63,0x06,0xC0,0x78,0x0F,0x01,0xE0,0x3C,0x07,0x80,0xD8,0x31,0x8C,0x1F,0x00,
// 'ԧ
0xD4,0x01,0x0B,0x11,0x01,0x0D,
0x00,0x00,0x80,0x28,0x00,0x00,0x00,0x3E,0x0C,0x63,0x06,0xC0,0x78,0x0F,0x01,0xE0,0x3C,0x07,0x80,0xD8,0x31,0x8C,0x1F,0x00,
// 'է
0xD5,0x02,0x0B,0x10,0x01,0x0D,
0x1C,0x00,0xE0,0x00,0x00,0x01,0xF0,0x63,0x18,0x36,0x03,0xC0,0x78,0x0F,0x01,0xE0,0x3C,0x06,0xC1,0x8C,0x60,0xF8,
// '֧
0xD6,0x03,0x0B,0x0F,0x01,0x0D,
0x11,0x02,0x20,0x00,0x0F,0x83,0x18,0xC1,0xB0,0x1E,0x03,0xC0,0x78,0x0F,0x01,0xE0,0x36,0x0C,0x63,0x07,0xC0,
// 'ק
0xD7,0x07,0x0C,0x09,0x00,0x0C,
0x60,0x63,0x0C,0x19,0x80,0xF0,0x06,0x00,0xF0,0x19,0x83,0x0C,0x60,0x60,
// 'ا
0xD8,0x05,0x0B,0x0E,0x01,0x0D,
0x00,0x03,0xE4,0xC3,0x30,0x6C,0x17,0x84,0xF1,0x9E,0x63,0xC8,0x7A,0x0D,0x83,0x30,0xC9,0xF0,0x00,0x00,
// '٧
0xD9,0x01,0x0D,0x11,0x00,0x0D,
0x08,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x38,0x38,0xC1,0x86,0x0C,0x30,0x61,0x83,0x0C,0x18,0x60,0xC3,0x06,0x18,0x30,0xC1,0x83,0x18,0x0F,0x80,
// 'ڧ
0xDA,0x01,0x0D,0x11,0x00,0x0D,
0x00,0x80,0x0C,0x00,0x40,0x04,0x00,0x00,0x38,0x38,0xC1,0x86,0x0C,0x30,0x61,0x83,0x0C,0x18,0x60,0xC3,0x06,0x18,0x30,0xC1,0x83,0x18,0x0F,0x80,
// 'ۧ
0xDB,0x01,0x0D,0x11,0x00,0x0D,
0x00,0x00,0x10,0x01,0x40,0x00,0x00,0x00,0x38,0x38,0xC1,0x86,0x0C,0x30,0x61,0x83,0x0C,0x18,0x60,0xC3,0x06,0x18,0x30,0xC1,0x83,0x18,0x0F,0x80,
// 'ܧ
0xDC,0x03,0x0D,0x0F,0x00,0x0D,
0x0C,0x80,0x44,0x00,0x00,0xE0,0xE3,0x06,0x18,0x30,0xC1,0x86,0x0C,0x30,0x61,0x83,0x0C,0x18,0x60,0xC3,0x06,0x0C,0x60,0x3E,0x00,
// 'ݧ
0xDD,0x01,0x0C,0x11,0x00,0x0C,
0x01,0x00,0x10,0x02,0x00,0x00,0x00,0x07,0x0E,0x30,0x81,0x18,0x19,0x00,0xB0,0x0E,0x00,0x60,0x06,0x00,0x60,0x06,0x00,0x60,0x0F,0x00,
// 'ާ
0xDE,0x06,0x0A,0x0C,0x00,0x0A,
0x78,0x0C,0x03,0xF0,0xC6,0x30,0xCC,0x33,0x0C,0xC6,0x3F,0x0C,0x03,0x01,0xE0,
// 'ߧ
0xDF,0x06,0x0A,0x0C,0x00,0x0A,
0x0F,0x04,0x63,0x18,0xC6,0x33,0x0C,0x83,0x10,0xC6,0x30,0xCF,0x33,0x99,0xDC,
// '্
0xE0,0x06,0x08,0x0C,0x00,0x08,
0x40,0x60,0x00,0x00,0x1C,0x26,0x46,0x3E,0x46,0x46,0x46,0x3E,
// '᧍
0xE1,0x06,0x07,0x0C,0x01,0x08,
0x08,0x30,0x40,0x07,0x99,0x83,0x3E,0x8D,0x1A,0x33,0xE0,
// '⧍
0xE2,0x05,0x07,0x0D,0x01,0x08,
0x00,0x20,0xE0,0x00,0x0F,0x33,0x06,0x7D,0x1A,0x34,0x67,0xC0,
// '㧍
0xE3,0x06,0x07,0x0C,0x01,0x08,
0x61,0x28,0x60,0x07,0x99,0x83,0x3E,0x8D,0x1A,0x33,0xE0,
// '䧍
0xE4,0x07,0x07,0x0B,0x01,0x08,
0x64,0x88,0x03,0xCC,0xC1,0x9F,0x46,0x8D,0x19,0xF0,
// '姍
0xE5,0x06,0x07,0x0C,0x01,0x08,
0x30,0x90,0xC0,0x07,0x99,0x83,0x3E,0x8D,0x1A,0x33,0xE0,
// '槍
0xE6,0x0A,0x0D,0x08,0x01,0x0E,
0x39,0xC6,0x31,0x01,0x84,0xEF,0xE8,0x60,0x43,0x02,0x18,0x4F,0x38,
// '种
0xE7,0x0A,0x07,0x0D,0x01,0x09,
0x3C,0xCB,0x1E,0x0C,0x18,0x18,0x9C,0x10,0x30,0x12,0x23,0x80,
// '觍
0xE8,0x06,0x08,0x0C,0x01,0x09,
0x40,0x20,0x10,0x00,0x38,0x44,0xC2,0xFE,0xC0,0xC0,0x42,0x38,
// '駍
0xE9,0x06,0x08,0x0C,0x01,0x09,
0x04,0x0C,0x08,0x00,0x38,0x44,0xC2,0xFE,0xC0,0xC0,0x42,0x38,
// '꧍
0xEA,0x05,0x08,0x0D,0x01,0x09,
0x00,0x10,0x38,0x00,0x00,0x38,0x44,0xC2,0xFE,0xC0,0xC0,0x42,0x38,
// '맍
0xEB,0x07,0x08,0x0B,0x01,0x09,
0x44,0x44,0x00,0x38,0x44,0xC6,0xFE,0xC0,0xC0,0x42,0x38,
// '짍
0xEC,0x06,0x06,0x0C,0x00,0x06,
0xC1,0x02,0x00,0x30,0xC3,0x0C,0x30,0xC3,0x1E,
// '�
0xED,0x06,0x06,0x0C,0x00,0x06,
0x08,0x61,0x00,0x30,0xC3,0x0C,0x30,0xC3,0x1E,
// '
0xEE,0x05,0x07,0x0D,0xFF,0x06,
0x00,0x20,0xE0,0x00,0x03,0x06,0x0C,0x18,0x30,0x60,0xC3,0xC0,
// '留
0xEF,0x07,0x06,0x0B,0x01,0x07,
0x8A,0x20,0x1C,0x30,0xC3,0x0C,0x30,0xC7,0x80,
// '𧍊
0xF0,0x05,0x08,0x0D,0x01,0x0A,
0x00,0x1B,0x1C,0x34,0x06,0x3E,0x67,0xC3,0xC3,0xC3,0xC3,0x66,0x3C,
// '񧍊
0xF1,0x06,0x0C,0x0C,0x00,0x0C,
0x0C,0x01,0x24,0x01,0x80,0x00,0x77,0x83,0x8C,0x30,0xC3,0x0C,0x30,0xC3,0x0C,0x30,0xC7,0x0E,
// '򧍊
0xF2,0x06,0x08,0x0C,0x01,0x0A,
0x60,0x20,0x10,0x00,0x3C,0x66,0xC3,0xC3,0xC3,0xC3,0x66,0x3C,
// '󧍊
0xF3,0x06,0x08,0x0C,0x01,0x0A,
0x06,0x04,0x08,0x00,0x3C,0x66,0xC3,0xC3,0xC3,0xC3,0x66,0x3C,
// '��
0xF4,0x05,0x08,0x0D,0x01,0x0A,
0x00,0x18,0x3C,0x00,0x00,0x3C,0x66,0xC3,0xC3,0xC3,0xC3,0x66,0x3C,
// '��
0xF5,0x06,0x08,0x0C,0x01,0x0A,
0x30,0x42,0x0C,0x00,0x3C,0x66,0xC3,0xC3,0xC3,0xC3,0x66,0x3C,
// '��0xF6,0x07,0x08,0x0B,0x01,0x0A,
0x24,0x24,0x00,0x3C,0x66,0xC3,0xC3,0xC3,0xC3,0x66,0x3C,
// '��
0xF7,0x08,0x07,0x07,0x02,0x0B,
0x10,0x20,0x07,0xF0,0x02,0x04,0x00,
// '𧍊0xF8,0x07,0x08,0x0E,0x01,0x0A,
0x00,0x02,0x02,0x3E,0x66,0xCB,0xCB,0xD3,0xD3,0x66,0x7C,0x40,0x40,0x00,
// '񧍊
0xF9,0x06,0x09,0x0C,0x01,0x0B,
0x20,0x18,0x04,0x00,0x0E,0x3B,0x19,0x8C,0xC6,0x63,0x31,0x98,0xC7,0xF0,
// '򧍊
0xFA,0x06,0x09,0x0C,0x01,0x0B,
0x02,0x03,0x01,0x00,0x0E,0x3B,0x19,0x8C,0xC6,0x63,0x31,0x98,0xC7,0xF0,
// '󧍊
0xFB,0x05,0x09,0x0D,0x01,0x0B,
0x00,0x04,0x07,0x00,0x00,0x07,0x1D,0x8C,0xC6,0x63,0x31,0x98,0xCC,0x63,0xF8,
// '��
0xFC,0x07,0x09,0x0B,0x01,0x0B,
0x32,0x11,0x00,0x1C,0x76,0x33,0x19,0x8C,0xC6,0x63,0x31,0x8F,0xE0,
// '��
0xFD,0x06,0x0B,0x10,0x00,0x0C,
0x01,0x00,0x60,0x08,0x00,0x07,0x0E,0x61,0x04,0x20,0xC8,0x09,0x01,0xE0,0x18,0x03,0x00,0x40,0xC8,0x12,0x01,0xC0,
// '��
0xFE,0x06,0x0A,0x10,0x00,0x0A,
0x60,0x0C,0x03,0x00,0xC0,0x3F,0x0C,0x63,0x08,0xC3,0x30,0xCC,0x23,0x18,0xFC,0x30,0x0C,0x03,0x01,0xE0,
// '��
0xFF,0x07,0x0C,0x0F,0x00,0x0C,
0x08,0x80,0x88,0x00,0x07,0x06,0x10,0x41,0x88,0x08,0x80,0xD0,0x05,0x00,0x60,0x02,0x00,0x20,0x64,0x04,0x40,0x38,0x00,

// Terminator
0xFF
};

Font: https://fonts2u.com/code2000.font

It there way to get and use special characters? (I'm interested in scandinavian "ÆØÅæøå" ).

Can I prepare bitmap with other tools somehow?

MichaelVLV commented 5 years ago

Also I'm trying to create proper .c array with this tool https://loboris.eu/ttf2fon but no success aswell.

Maybe I'm set wrong settings?

Settings: image

Result: image