Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom fonts not working #17

Open
x16 opened this issue Sep 28, 2017 · 1 comment
Open

Custom fonts not working #17

x16 opened this issue Sep 28, 2017 · 1 comment

Comments

@x16
Copy link

x16 commented Sep 28, 2017

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
Copy link
Author

x16 commented Nov 1, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant