esp32 t-display + cyrillic

Hello! It’s need to display some cyrillic-text (russian and ukraine) on this display. I try to use font with this charters from here and use it:

#include "fonts/GlametrixLight12pt7b.h";

TFT_eSPI tft = TFT_eSPI();

char *utf8rus_P(const char *source)
{
  char m[2] = { '0', '\0' };
  int j = 0;
  unsigned char n = 1;

  strcpy(target, "");

  while (1) {
    n = pgm_read_byte(source); source++;

    if (n >= 0xC0) {
      switch (n) {
        case 0xD0: {
          n = pgm_read_byte(source); source++;

          if (n == 0x81) { n = 0xA8; break; }
          if (n >= 0x90 && n <= 0xBF) n = n + 0x30;
          break;
        }
        case 0xD1: {
          n = pgm_read_byte(source); source++;

          if (n == 0x91) { n = 0xB8; break; }
          if (n >= 0x80 && n <= 0x8F) n = n + 0x70;
          break;
        }
      }
    }
    if (n == 0) break;

    m[0] = n; strcat(target, m);
    j++; if (j >= maxString) break;
  }
  return target;
}

loop ()

{

  tft.setTextSize(1);
tft.setCursor(0, 20);
tft.setFreeFont(&GlametrixLight12pt7b);
tft.println(utf8rus_P("Привет"));

}

but it’s not any on display… Please help, how show cyrillic symbol? Thanks!

Thread moved as requested.

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 suggest that you try his examples first.

I might try them myself later this morning.

David.

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

David.

cool! Thank! It's work!!!

In theory you could mix Latin, Greek, Cyrillic, Arabic, ... UTF8 text in one statement. (providing that your font supports all of those styles)

Ug2_for_Adafruit_GFX fonts allow you to mix Latin and Cyrillic in one UTF8 string.

And obviously Chinese text has many more than 256 letters !

David.

Thanks you! And maybe somehow I can convert my fonts to this format?

This topic was automatically closed after 120 days. New replies are no longer allowed.