Hello World in Japanese

Description

I am connecting ili9488 to ESP32 and creating a screen display using the lvgl library.

I have confirmed that the program that displays Hello World on the screen can be displayed normally.

Next time, I would like to display “こんにちは、世界!” in Japanese.

Do I have to create Japanese files from True Type fonts on this site?

Are there any files that are already available?

What MCU/Processor/Board and compiler are you using?

ESP32, platformio

What LVGL version are you using?

lvgl@ 8.3.9

What do you want to achieve?

I would like to display “Hello World” in Japanese.

What have you tried so far?

There is a file called NotoSerifJP-Medium.otf which is Google’s Japanese font.

Unicode for hiragana-only fonts in this file

0x304-0x309F

Up to this point, the file jpfont.c has been output.

I put the main.cpp and jphont.c files in the same src folder and the build was OK, but the hiragana font of “あいうえおかきくけこ” is not displayed on the ili9488 screen at all.

Is this the correct way to create Japanese fonts?

Is the jphont.c file loaded correctly?

Please tell me how to solve it.

#include <Arduino.h>
#include <lvgl.h>
#include <TFT_eSPI.h> // ILI9488ドライバを含むライブラリ


TFT_eSPI tft = TFT_eSPI(); // TFTのインスタンスを作成

// ディスプレイフラッシュ関数
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
    tft.startWrite();
    tft.setAddrWindow(area->x1, area->y1, area->x2 - area->x1 + 1, area->y2 - area->y1 + 1);
    tft.pushColors((uint16_t *)&color_p->full, (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1), true);
    tft.endWrite();
    lv_disp_flush_ready(disp);
}

static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[320 * 10]; // 仮にディスプレイの垂直解像度を480ピクセルと仮定
static lv_disp_drv_t disp_drv;

LV_FONT_DECLARE(jpfont);

void setup() {
    Serial.begin(115200); // シリアル通信の初期化
    Serial.println("Setup Start");

    lv_init();
    tft.begin();
    tft.setRotation(1); // ディスプレイの向きに合わせて調整

    // バッファのサイズを設定(解像度に基づいて)


    lv_disp_draw_buf_init(&draw_buf, buf, NULL, 320 * 3);

    lv_disp_drv_init(&disp_drv);
    disp_drv.hor_res = 480; // ディスプレイの解像度を設定
    disp_drv.ver_res = 320;
    disp_drv.flush_cb = my_disp_flush;
    disp_drv.draw_buf = &draw_buf;
    lv_disp_drv_register(&disp_drv);


    static lv_style_t style1;
    // LVGLラベルの作成
    lv_obj_t *label = lv_label_create(lv_scr_act());
    //lv_label_set_text(label, "Hello, LVGL World02!");
    lv_style_init(&style1);
    lv_style_set_text_font(&style1, &jpfont);

    lv_obj_add_style(label, &style1, 0);
    lv_style_set_text_color(&style1, lv_color_hex(0xFFFFFF));
    lv_label_set_text(label,"あいうえおかきくけこ");
    // ラベルのサイズを設定
    lv_obj_set_size(label, 200, 100);

    // テキストの折り返しを設定
    lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);

    lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);

    Serial.println("Setup End");
}

void loop() {
    lv_task_handler();
    delay(5);
}