sumotoy / TFT_ST7735

A fast driver for ST7735 displays that works with Arduino's /All Teensy's/ESP8266/SPARK
69 stars 31 forks source link

Custom fonts not working #17

Open x16 opened 7 years ago

x16 commented 7 years ago

AquariusSmall.zip Just tried to create my own font file and cannot load it: when I call tft.setFont(&AquariusSmall);//this will load the font it does not change the font face.

Full code: #include <SPI.h> #include <TFT_ST7735.h> #include "_fonts/AquariusSmall.c"

#define __CS 16 //CS to GPIO16 #define __DC 5 //RS/A0 to GPIO5

TFT_ST7735 tft = TFT_ST7735(__CS, __DC);//we dont use rst, tie reset pin to 3v3

void setup() { Serial.begin(115200); Serial.print("\nstarted\n"); tft.begin(); tft.setRotation(1);//90 degree so it would be 160x128 instead of 128x160 tft.setFont(&AquariusSmall);//this will load the font tft.println("Hello world!");//this will add a new line as well tft.setTextScale(2);//now multiply x 3 the scale tft.println("Hello world!");//the wrap on will split words in 2 lines tft.setInternalFont();//now switch to internal font tft.setTextScale(2);//smaller tft.setFontInterline(2);//this will be active after the println! tft.println("Hello world!"); tft.setCharSpacing(1);//add an extra pixel between chars tft.setTextColor(YELLOW, BLACK); //set a background inside font tft.println("Hello world!"); }

void loop() {

}

Font file contains latin+cyrillic chars ( !"#$%&'()*+,-./0123456789:;<=>?\x0040ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯабвгдеёжзийклмнопрстуфхцчшщьыъэюяҐґЇїЄє).

Font file is in attachment. Thanks.

x16 commented 7 years ago

Made it working. But now I cannot use cyrillic characters in normal form i.e. I cannot just write "Їїїїъъ" but have to write "\xaf\xbf\xbf\xbf\xfa\xfa" instead. Saved font mapped as Windows-1251.