# TFT eSPI + ESP32 - русификация

**URL:** <https://forum.arduino.ru/t/tft-espi-esp32-rusifikacziya/11646>\
**Category:** Программирование\
**Tags:** esp32\
**Created:** [30.Август.2023 08:10:17 UTC](https://forum.arduino.ru/t/tft-espi-esp32-rusifikacziya/11646 "2023-08-30T08:10:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rankle](https://forum.arduino.ru/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@Rankle](https://forum.arduino.ru/u/Rankle)\
**Post date:** [30.Август.2023 08:10:17 UTC](https://forum.arduino.ru/t/tft-espi-esp32-rusifikacziya/11646/1 "2023-08-30T08:10:17Z")

</div>

Добрый день. Тема неоднократно поднималась, есть примеры (некоторые даже рабочие).  
Я сам пробовал рабочие скетчи. НО! Мне кажется что шрифты у меня хоть и подгружаются (я работаю со SPIFFS) но сообщения на русском выводятся каким-то шрифтом “по умолчанию”.  
Поясню.

```arduino
tft.loadFont(FONT_A30)
tft.showFont(2000);
tft.unloadFont();

```

результат работы:

 ![IMG_20230830_115403](https://forum.arduino.ru/uploads/default/original/2X/4/4d99d875d0c05c43a44f091d2564d8dbc6fc3a45.jpeg)

```arduino
tft.loadFont(FONT_A30);
tft.drawString(utf8rus("ПРИВЕТ"),0,0,4);
tft.unloadFont();
  

```

или

```arduino
tft.loadFont(FONT_A30);
tft.println("ПРИВЕТ");
tft.unloadFont();
  

```

результат работы:

 ![IMG_20230830_115539](https://forum.arduino.ru/uploads/default/original/2X/9/92651ae30c42027fe0994eff7b99d3451149b266.jpeg)

Понимая, что может быть utf8rus “кривая” и неправильно задано смещение, я начал выводить всё подряд посимвольно смотря где же русские буквы.

```arduino
for ( int x = 0x0021; x<= 0x007F; x++)
{
  tft.print(x); tft.print("-"); tft.print((char)(x)); tft.print("*");
  delay (500);
}
for ( int x = 0x0400; x<= 0x04FF; x++)
{
  tft.print(x); tft.print("-"); tft.print((char)(x)); tft.print("*");
  delay (500);
}
for ( int x = 0x0500; x<= 0x052F; x++)
{
  tft.print(x); tft.print("-"); tft.print((char)(x)); tft.print("*");
  delay (500);
}

```

(меняя начало по X что бы на экран всё влезло)  
результат:

 ![IMG_20230830_122848](https://forum.arduino.ru/uploads/default/original/2X/3/337ae79616b895025e8a8f1b66f1af91ca820831.jpeg)

Вместо русских символов - прямоугольники.  
Где русские символы?  
Что я упускаю? Где ошибка?

Запускал скетч работы со SPIFFS. Нет, всё нормально читается.

```arduino
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0

Initialisation done.

SPIFFS files found:
Listing directory: /
  anonymouspro30.vlw 145482 bytes
  Arial20.vlw 65515 bytes
  Arial22.vlw 75848 bytes
  Arial25.vlw 94315 bytes
  SitkaBannerItalic30.vlw 62215 bytes
  UbuntuMonoB30.vlw 145481 bytes
  Arial30.vlw 134860 bytes
  ptmonobold30.vlw 145480 bytes

```

В файле User\_Setup.h я закоментировал строки с дефолтными шрифтами

```arduino
//#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
//#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
//#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
//#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
//#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH
#define SMOOTH_FONT

```

---

<div class="post-metadata">

**Author:** ![b707](https://forum.arduino.ru/user_avatar/forum.arduino.ru/b707/32/354_2.png) [@b707](https://forum.arduino.ru/u/b707)\
**Post date:** [30.Август.2023 11:16:06 UTC](https://forum.arduino.ru/t/tft-espi-esp32-rusifikacziya/11646/2 "2023-08-30T11:16:06Z")

</div>

> [@Rankle](#):
>
> ```auto
> for ( int x = 0x0400; x<= 0x04FF; x++)
> {
> tft.print(x); tft.print("-"); tft.print((char)(x)); tft.print("*");
> delay (500);
> }
> 
> ```

Видите ли, тип char - это один байт. И потому пытаться вывести на экран значение в пределах  
`for ( int x = 0x0400; x<= 0x04FF; x++)`  
с помощью оператора `tft.print((char)(x));`бессмысленно.

Вам надо разобраться, какая у вас кодировка в Ардуино скетче, какая в фонте и соответствует ли используемая функция utf8rus переводу первой кодовой таблицы во вторую
