diff --git a/src/draw/lv_draw_label.c b/src/draw/lv_draw_label.c index 8a1ebe12df..54dea2bc7e 100644 --- a/src/draw/lv_draw_label.c +++ b/src/draw/lv_draw_label.c @@ -100,6 +100,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_letter(lv_layer_t * layer, lv_draw_label_dsc_ return; } + if(_lv_text_is_marker(unicode_letter)) return; + lv_font_glyph_dsc_t g; lv_font_get_glyph_dsc(dsc->font, &g, unicode_letter, 0); @@ -362,16 +364,14 @@ static void draw_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc, { lv_font_glyph_dsc_t g; + if(_lv_text_is_marker(letter)) /*Markers are valid letters but should not be rendered.*/ + return; + LV_PROFILER_BEGIN; bool g_ret = lv_font_get_glyph_dsc(font, &g, letter, '\0'); if(g_ret == false) { - /*Add warning if the dsc is not found - *but do not print warning for non printable ASCII chars (e.g. '\n')*/ - if(letter >= 0x20 && - letter != 0xf8ff && /*LV_SYMBOL_DUMMY*/ - letter != 0x200c) { /*ZERO WIDTH NON-JOINER*/ - LV_LOG_WARN("lv_draw_letter: glyph dsc. not found for U+%" LV_PRIX32, letter); - } + /*Add warning if the dsc is not found*/ + LV_LOG_WARN("lv_draw_letter: glyph dsc. not found for U+%" LV_PRIX32, letter); } /*Don't draw anything if the character is empty. E.g. space*/ diff --git a/src/font/lv_font.c b/src/font/lv_font.c index c510f0aa5b..8fd7da9566 100644 --- a/src/font/lv_font.c +++ b/src/font/lv_font.c @@ -8,9 +8,11 @@ *********************/ #include "lv_font.h" +#include "../misc/lv_text.h" #include "../misc/lv_utils.h" #include "../misc/lv_log.h" #include "../misc/lv_assert.h" +#include "../stdlib/lv_string.h" /********************* * DEFINES @@ -86,21 +88,13 @@ bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_o } #endif - 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 { #if LV_USE_FONT_PLACEHOLDER - dsc_out->box_w = font_p->line_height / 2; - dsc_out->adv_w = dsc_out->box_w + 2; + dsc_out->box_w = font_p->line_height / 2; + dsc_out->adv_w = dsc_out->box_w + 2; #else - dsc_out->box_w = 0; - dsc_out->adv_w = 0; + dsc_out->box_w = 0; + dsc_out->adv_w = 0; #endif - } dsc_out->resolved_font = NULL; dsc_out->box_h = font_p->line_height; @@ -116,6 +110,10 @@ uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32 { LV_ASSERT_NULL(font); lv_font_glyph_dsc_t g; + + /*Return zero if letter is marker*/ + if(_lv_text_is_marker(letter)) return 0; + lv_font_get_glyph_dsc(font, &g, letter, letter_next); return g.adv_w; } diff --git a/src/misc/lv_text.h b/src/misc/lv_text.h index 16639744de..b2eddab4e3 100644 --- a/src/misc/lv_text.h +++ b/src/misc/lv_text.h @@ -220,6 +220,41 @@ static inline bool _lv_text_is_a_word(uint32_t letter) return false; } +/** + * Test if character can be treated as marker, and don't need to be rendered. + * Note, this is not a full list. Add your findings to the list. + * + * @param letter a letter + * @return true if so + */ +static inline bool _lv_text_is_marker(uint32_t letter) +{ + if(letter < 0x20) return true; + + /*U+061C ARABIC LETTER MARK, see https://www.compart.com/en/unicode/block/U+0600*/ + if(letter == 0x061C) return true; + + /*U+115F HANGUL CHOSEONG FILLER, See https://www.compart.com/en/unicode/block/U+1100*/ + if(letter == 0x115F) return true; + /*U+1160 HANGUL JUNGSEONG FILLER*/ + if(letter == 0x1160) return true; + + /*See https://www.compart.com/en/unicode/block/U+1800*/ + if(letter >= 0x180B && letter <= 0x180E) return true; + + /*See https://www.compart.com/en/unicode/block/U+2000*/ + if(letter >= 0x200B && letter <= 0x200F) return true; + if(letter >= 0x2028 && letter <= 0x202F) return true; + if(letter >= 0x205F && letter <= 0x206F) return true; + + /*U+FEFF ZERO WIDTH NO-BREAK SPACE, see https://www.compart.com/en/unicode/block/U+FE70*/ + if(letter == 0xFEFF) return true; + + if(letter == 0xF8FF) return true; /*LV_SYMBOL_DUMMY*/ + + return false; +} + /*************************************************************** * GLOBAL FUNCTION POINTERS FOR CHARACTER ENCODING INTERFACE ***************************************************************/