#pragma once

#ifndef HW_LIB_FONT_T_H
#define HW_LIB_FONT_T_H

#ifdef __cplusplus
extern "C" {
#endif
#include "stdlib.h"
#include "string.h"
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "lvgl_font.h"

// 定义像素颜色的位数
#define PIX_COLOR_SIZE 16

// 启用单行刷新
//#define LINE_FAST_SHOW

typedef struct Font Font_f_t;
#if PIX_COLOR_SIZE == 1
typedef void (*Font_Show_t)(Font_f_t *font, uint8_t *data, size_t len);
#endif
#if PIX_COLOR_SIZE == 16
typedef void (*Font_Show_t)(Font_f_t *font, uint16_t *data, size_t len);
#endif
struct Font {
    void *dev;
    uint16_t dev_w;
    uint16_t x, y, w, h;
    Font_Show_t show;
#if PIX_COLOR_SIZE == 16
    uint16_t pixcolor;
    uint16_t backgroundcolor;
#endif
};

uint8_t Font_utf8_to_unicode(uint8_t *pInput, uint32_t *unicode_letter);

uint8_t Font_draw_letter(const lv_font_t *font, Font_f_t *fd, uint32_t letter, int16_t pos_x, int16_t pos_y);

#ifdef __cplusplus
}
#endif

#endif