/*******************************************************************************
 * Size: 10 px
 * Bpp: 4
 * Opts: --bpp 4 --size 10 --no-compress --font 微软雅黑.ttf --symbols x1000r/min23456789. --format lvgl -o MXC_MSYAHEI_CT_bpp4_10px.c
 ******************************************************************************/

#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif

#ifndef MXC_MSYAHEI_CT_BPP4_10PX
#define MXC_MSYAHEI_CT_BPP4_10PX 1
#endif

#if MXC_MSYAHEI_CT_BPP4_10PX

/*-----------------
 *    BITMAPS
 *----------------*/

/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
    /* U+002E "." */
    0x2, 0x4b,

    /* U+002F "/" */
    0x0, 0x0, 0xb2, 0x0, 0x1, 0xc0, 0x0, 0x7,
    0x60, 0x0, 0xd, 0x0, 0x0, 0x4a, 0x0, 0x0,
    0xa4, 0x0, 0x0, 0xd0, 0x0, 0x6, 0x70, 0x0,
    0xc, 0x10, 0x0, 0x6, 0x0, 0x0,

    /* U+0030 "0" */
    0x6, 0xed, 0x50, 0x1e, 0x11, 0xe0, 0x69, 0x0,
    0xb4, 0x87, 0x0, 0x96, 0x87, 0x0, 0x96, 0x68,
    0x0, 0xb4, 0x2e, 0x11, 0xd0, 0x6, 0xdd, 0x40,

    /* U+0031 "1" */
    0x0, 0x2, 0x0, 0x1b, 0xf9, 0x0, 0x3, 0x69,
    0x0, 0x0, 0x69, 0x0, 0x0, 0x69, 0x0, 0x0,
    0x69, 0x0, 0x0, 0x69, 0x0, 0x0, 0x69, 0x0,
    0x1e, 0xef, 0xe3,

    /* U+0032 "2" */
    0x9, 0xde, 0x60, 0x15, 0x1, 0xe1, 0x0, 0x0,
    0xd2, 0x0, 0x3, 0xc0, 0x0, 0x1c, 0x20, 0x1,
    0xc3, 0x0, 0x1c, 0x30, 0x0, 0x7f, 0xff, 0xf1,

    /* U+0033 "3" */
    0xb, 0xdd, 0x40, 0x1, 0x4, 0xc0, 0x0, 0x6,
    0x90, 0x7, 0xed, 0x10, 0x0, 0x5, 0xd0, 0x0,
    0x0, 0xe1, 0x21, 0x3, 0xd0, 0x2d, 0xdc, 0x30,

    /* U+0034 "4" */
    0x0, 0xd, 0x80, 0x0, 0x8b, 0x80, 0x2, 0xb6,
    0x80, 0xb, 0x26, 0x80, 0x77, 0x6, 0x80, 0xcd,
    0xde, 0xe6, 0x0, 0x6, 0x80, 0x0, 0x6, 0x80,

    /* U+0035 "5" */
    0xe, 0xee, 0xb0, 0xe, 0x0, 0x0, 0xe, 0x0,
    0x0, 0xe, 0xec, 0x30, 0x0, 0x4, 0xe0, 0x0,
    0x0, 0xd1, 0x1, 0x3, 0xe0, 0x1d, 0xdc, 0x30,

    /* U+0036 "6" */
    0x1, 0xae, 0xd0, 0xa, 0x70, 0x0, 0x2d, 0x0,
    0x0, 0x4b, 0xbd, 0x80, 0x6d, 0x10, 0xd3, 0x4a,
    0x0, 0x96, 0x1d, 0x10, 0xd3, 0x5, 0xdd, 0x70,

    /* U+0037 "7" */
    0x8e, 0xee, 0xf4, 0x0, 0x0, 0xd0, 0x0, 0x6,
    0x80, 0x0, 0xc, 0x20, 0x0, 0x2c, 0x0, 0x0,
    0x96, 0x0, 0x0, 0xe0, 0x0, 0x6, 0x90, 0x0,

    /* U+0038 "8" */
    0x6, 0xde, 0x60, 0x1e, 0x1, 0xe0, 0x1e, 0x1,
    0xe0, 0x5, 0xdd, 0x40, 0xb, 0x46, 0xb0, 0x68,
    0x0, 0xa4, 0x5b, 0x0, 0xd3, 0xa, 0xed, 0x70,

    /* U+0039 "9" */
    0x7, 0xdd, 0x40, 0x4c, 0x1, 0xd0, 0x77, 0x0,
    0xb3, 0x4c, 0x1, 0xe5, 0x8, 0xdb, 0xb3, 0x0,
    0x0, 0xd1, 0x0, 0x6, 0xa0, 0x1d, 0xeb, 0x10,

    /* U+0069 "i" */
    0x2c, 0x2, 0x0, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
    0x2d,

    /* U+006D "m" */
    0x2d, 0x8c, 0x97, 0xbc, 0x12, 0xf1, 0xe, 0x80,
    0x78, 0x2d, 0x0, 0xb3, 0x5, 0x92, 0xd0, 0xb,
    0x30, 0x5a, 0x2d, 0x0, 0xb3, 0x5, 0xa2, 0xd0,
    0xb, 0x30, 0x5a,

    /* U+006E "n" */
    0x2d, 0x8b, 0xb0, 0x2f, 0x20, 0xb4, 0x2d, 0x0,
    0x86, 0x2d, 0x0, 0x86, 0x2d, 0x0, 0x86, 0x2d,
    0x0, 0x86,

    /* U+0072 "r" */
    0x0, 0x0, 0x2d, 0xab, 0x2f, 0x30, 0x2d, 0x0,
    0x2d, 0x0, 0x2d, 0x0, 0x2d, 0x0,

    /* U+0078 "x" */
    0x89, 0x6, 0xa0, 0xd2, 0xd1, 0x5, 0xd7, 0x0,
    0x5e, 0x60, 0xd, 0x2d, 0x19, 0x70, 0x79
};


/*---------------------
 *  GLYPH DESCRIPTION
 *--------------------*/

static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
    {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
    {.bitmap_index = 0, .adv_w = 39, .box_w = 2, .box_h = 2, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 2, .adv_w = 68, .box_w = 6, .box_h = 10, .ofs_x = -1, .ofs_y = -2},
    {.bitmap_index = 32, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 56, .adv_w = 94, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 83, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 107, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 131, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 155, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 179, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 203, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 227, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 251, .adv_w = 94, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 275, .adv_w = 43, .box_w = 2, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 284, .adv_w = 150, .box_w = 9, .box_h = 6, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 311, .adv_w = 99, .box_w = 6, .box_h = 6, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 329, .adv_w = 61, .box_w = 4, .box_h = 7, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 343, .adv_w = 81, .box_w = 5, .box_h = 6, .ofs_x = 0, .ofs_y = 0}
};

/*---------------------
 *  CHARACTER MAPPING
 *--------------------*/

static const uint16_t unicode_list_1[] = {
    0x0, 0x4, 0x5, 0x9, 0xf
};

/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
    {
        .range_start = 46, .range_length = 12, .glyph_id_start = 1,
        .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
    },
    {
        .range_start = 105, .range_length = 16, .glyph_id_start = 13,
        .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 5, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
    }
};

/*-----------------
 *    KERNING
 *----------------*/


/*Pair left and right glyphs for kerning*/
static const uint8_t kern_pair_glyph_ids[] =
{
    16, 1,
    16, 14,
    16, 15,
    16, 17
};

/* Kerning between the respective left and right glyphs
 * 4.4 format which needs to scaled with `kern_scale`*/
static const int8_t kern_pair_values[] =
{
    -14, 0, 0, 5
};

/*Collect the kern pair's data in one place*/
static const lv_font_fmt_txt_kern_pair_t kern_pairs =
{
    .glyph_ids = kern_pair_glyph_ids,
    .values = kern_pair_values,
    .pair_cnt = 4,
    .glyph_ids_size = 0
};

/*--------------------
 *  ALL CUSTOM DATA
 *--------------------*/

#if LVGL_VERSION_MAJOR == 8
/*Store all the custom data of the font*/
static  lv_font_fmt_txt_glyph_cache_t cache;
#endif

#if LVGL_VERSION_MAJOR >= 8
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif
    .glyph_bitmap = glyph_bitmap,
    .glyph_dsc = glyph_dsc,
    .cmaps = cmaps,
    .kern_dsc = &kern_pairs,
    .kern_scale = 16,
    .cmap_num = 2,
    .bpp = 4,
    .kern_classes = 0,
    .bitmap_format = 0,
#if LVGL_VERSION_MAJOR == 8
    .cache = &cache
#endif
};



/*-----------------
 *  PUBLIC FONT
 *----------------*/

/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t MXC_MSYAHEI_CT_bpp4_10px = {
#else
lv_font_t MXC_MSYAHEI_CT_bpp4_10px = {
#endif
    .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt,    /*Function pointer to get glyph's data*/
    .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt,    /*Function pointer to get glyph's bitmap*/
    .line_height = 11,          /*The maximum line height required by the font*/
    .base_line = 2,             /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
    .subpx = LV_FONT_SUBPX_NONE,
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8
    .underline_position = -1,
    .underline_thickness = 1,
#endif
    .dsc = &font_dsc,          /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9
    .fallback = NULL,
#endif
    //.user_data = NULL,
};



#endif /*#if MXC_MSYAHEI_CT_BPP4_10PX*/

