|
由于LVGL8.1以后字体增加了:uint8_t is_placeholder: 1; /** Glyph is missing. But placeholder will still be displayed */
/** Describes the properties of a glyph.*/
typedef struct {
const struct _lv_font_t *
resolved_font; /**< Pointer to a font where the gylph was actually found after handling fallbacks*/
uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width.*/
uint16_t box_w; /**< Width of the glyph's bounding box*/
uint16_t box_h; /**< Height of the glyph's bounding box*/
int16_t ofs_x; /**< x offset of the bounding box*/
int16_t ofs_y; /**< y offset of the bounding box*/
uint8_t bpp: 4; /**< Bit-per-pixel: 1, 2, 4, 8*/
uint8_t is_placeholder: 1; /** Glyph is missing. But placeholder will still be displayed */
} lv_font_glyph_dsc_t;
会时不时引起这个错误:[Error] (0.291, +0) lv_font_get_glyph_bitmap: Asserted at expression: font_p != NULL (NULL pointer) (in lv_font.c line #51)
解决办法字体取模后要增加:dsc_out->is_placeholder = false;
static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
if( unicode_letter<fdsc->cmaps[0].range_start || unicode_letter>fdsc->cmaps[0].range_length ) return false;
int i;
if( unicode_letter==fdsc->cache->last_letter ){
i = fdsc->cache->last_glyph_id;
}
else{
i = binsearch(fdsc->cmaps[0].unicode_list, fdsc->cmaps[0].list_length, unicode_letter);
}
if( i != -1 ) {
const lv_font_fmt_txt_glyph_dsc_t * gdsc = &fdsc->glyph_dsc[i];
fdsc->cache->last_glyph_id = i;
fdsc->cache->last_letter = unicode_letter;
dsc_out->adv_w = gdsc->adv_w;
dsc_out->box_h = gdsc->box_h;
dsc_out->box_w = gdsc->box_w;
dsc_out->ofs_x = gdsc->ofs_x;
dsc_out->ofs_y = gdsc->ofs_y;
dsc_out->bpp = fdsc->bpp;
dsc_out->is_placeholder = false;//add202207
return true;
}
return false;
}
|
|