font: add cmap type

This commit is contained in:
Gabor Kiss-Vamosi
2019-05-28 08:06:15 +02:00
parent 005a7954ca
commit a5bbb5e651
2 changed files with 23 additions and 8 deletions

View File

@@ -2,11 +2,7 @@
#include "lvgl/lvgl.h"
/***********************************************************************************
* Size: 20 px
* Bpp: 1 (or 2/4/8/compressed)
* Fonts:
* DejaVuSans.ttf: U+0020 ( ) .. U+007e (~) range
* FoneAwesome.ttf: U+1e20 (?) .. U+1f22 (?), U+1f33 (?), U+1f66 (?)
* Copy/Paste the command line instruction
**********************************************************************************/
/*-----------------
@@ -59,9 +55,17 @@ static uint8_t glyph_id_ofs_list_3 = {32, 45, 66};
/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_cmap_fmt_txt_t cmaps[] = {
{ .range_start = 0x280, .range_length = 124, .glyph_id_start = 223, .unicode_list = unicode_list_1, .glyph_id_ofs_list = glyph_id_ofs_list_1},
{ .range_start = 0x20, .range_length = 112, .glyph_id_start = 456, .unicode_list = NULL, .glyph_id_ofs_list = NULL},
{ .range_start = 0x560, .range_length = 7654, .glyph_id_start = 756, .unicode_list = NULL, .glyph_id_ofs_list = glyph_id_ofs_list_3},
{
.range_start = 0x280, .range_length = 124, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_FULL,
.glyph_id_start = 223, .unicode_list = unicode_list_1, .glyph_id_ofs_list = glyph_id_ofs_list_1
},
{
.range_start = 0x20, .range_length = 112, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY,
.glyph_id_start = 456, .unicode_list = NULL, .glyph_id_ofs_list = NULL
},
{
.range_start = 0x560, .range_length = 7654, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL,
.glyph_id_start = 756, .unicode_list = NULL, .glyph_id_ofs_list = glyph_id_ofs_list_3},
};

View File

@@ -45,6 +45,15 @@ typedef struct
uint8_t ofs_y; /*y offset of the bounding box. Measured from the top of the line*/
}lv_font_glyph_dsc_fmt_txt_t;
typedef enum {
LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY,
LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL,
LV_FONT_FMT_TXT_CMAP_SPARSE_TINY,
LV_FONT_FMT_TXT_CMAP_SPARSE_FULL,
}lv_font_fmt_txt_cmap_type_t;
/* Map codepoints to a `glyph_dsc`s
* Several formats are supported to optimize memory usage
* See https://github.com/littlevgl/lv_font_conv/blob/master/doc/font_spec.md
@@ -60,6 +69,8 @@ typedef struct {
/* First glyph ID (array index of `glyph_dsc`) for this range */
uint16_t glyph_id_start;
lv_font_fmt_txt_cmap_type_t type;
/*
According the specification there are 4 formats:
https://github.com/littlevgl/lv_font_conv/blob/master/doc/font_spec.md