From 7cf5709b0669ab64e437a796c50f6bdb97b9d0d5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 16 Feb 2022 09:06:45 +0100 Subject: [PATCH] fix(font): use 0 width for non printable characters --- src/font/lv_font.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/font/lv_font.c b/src/font/lv_font.c index 8389e61dc..9c4115cb2 100644 --- a/src/font/lv_font.c +++ b/src/font/lv_font.c @@ -64,8 +64,10 @@ const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t lett bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next) { + LV_ASSERT_NULL(font_p); LV_ASSERT_NULL(dsc_out); + const lv_font_t * placeholder_font = NULL; const lv_font_t * f = font_p; @@ -91,9 +93,19 @@ bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_o return true; } + + if(letter < 0x20 || + letter == 0xf8ff || /*LV_SYMBOL_DUMMY*/ + letter == 0x200c) { /*ZERO WIDTH NON-JOINER*/ + dsc_out->box_w = 0; + dsc_out->adv_w = 0; + } + else { + dsc_out->box_w = font_p->line_height / 2; + dsc_out->adv_w = dsc_out->box_w + 2; + } + dsc_out->resolved_font = NULL; - dsc_out->box_w = font_p->line_height / 2; - dsc_out->adv_w = dsc_out->box_w + 2; dsc_out->box_h = font_p->line_height; dsc_out->ofs_x = 0; dsc_out->ofs_y = 0;