Most TFT, OLED, GLCD hardware libraries support Adafruit_GFX graphics.
Install Ug2lib_for_Adafruit_GFX via the IDE Library Manager.
Then you can use any of the U8g2 fonts and display UTF-8 strings e.g.
u8g2_for_adafruit_gfx.setFont(u8g2_font_unifont_t_extended); // extended font
u8g2_for_adafruit_gfx.setFontMode(1); // use u8g2 transparent mode (this is default)
u8g2_for_adafruit_gfx.setCursor(0, 40); // start writing at this position
u8g2_for_adafruit_gfx.print("<Ȧǀʘ>"); // UTF-8 string: "<" 550 448 664 ">"
Ah-ha. I see that you are using Bodmer’s TFT_eSPI hardware library.
TFT_eSPI supports UTF-8 strings by default (I think)
I tried the “Unicode_test” example. It uses Bodmer’s default Font format. Not FreeFont
So I tried:
#include <TFT_eSPI.h> // Hardware-specific library
// From https://github.com/board707/DMD_STM32/blob/master/gfx_fonts/GlametrixLight12pt7b.h
#include "GlametrixLight12pt7b.h";
TFT_eSPI tft = TFT_eSPI();
void setup(void)
{
tft.begin();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
tft.setTextSize(1);
}
void loop ()
{
tft.setTextColor(TFT_RED);
tft.setCursor(0, 30);
tft.setFreeFont(&GlametrixLight12pt7b);
tft.println("Write regular ascii with");
tft.println("GlametrixLight12pt7b Font");
tft.println("Change to Cyrillic Font");
tft.setFreeFont(&GlametrixLight12pt8b_rus);
tft.setTextColor(TFT_BLUE);
tft.println("Regular ascii does not print");
tft.println("Привет"); //Cyrillic prints ok
}
Which “worked” but requires you to change font whenever you go from ASCII to Cyrillic.
In theory you could mix Latin, Greek, Cyrillic, Arabic, … UTF8 text in one statement. (providing that your font supports all of those styles)
I am sure that this can work with TFT_eSPI but you might need to use a different Font format.
Perhaps a TFT_eSPI expert can advise.
I have only used UTF8 with Ug2_for_Adafruit_GFX which does not work with TFT_eSPI