From 110923168ad4bb8a5673a505ee0f632e1bc066f4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 14 Nov 2019 10:49:41 +0100 Subject: [PATCH] lv_font_fmt_txt: change tab to 2 spaces --- src/lv_font/lv_font_fmt_txt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index a67659ba8..2d337341d 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -76,6 +76,8 @@ static rle_state_t rle_state; */ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unicode_letter) { + if(unicode_letter == '\t') unicode_letter = ' '; + lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc; uint32_t gid = get_glyph_dsc_id(font, unicode_letter); if(!gid) return false; @@ -125,6 +127,13 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic */ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + + + bool is_tab = false; + if(unicode_letter == '\t') { + unicode_letter = ' '; + is_tab = true; + } lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc; uint32_t gid = get_glyph_dsc_id(font, unicode_letter); if(!gid) return false; @@ -142,7 +151,12 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * int32_t kv = ((int32_t)((int32_t)kvalue * fdsc->kern_scale) >> 4); - uint32_t adv_w = gdsc->adv_w + kv; + + + uint32_t adv_w = gdsc->adv_w; + if(is_tab) adv_w *= 2; + + adv_w += kv; adv_w = (adv_w + (1 << 3)) >> 4; dsc_out->adv_w = adv_w; @@ -152,6 +166,8 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out->ofs_y = gdsc->ofs_y; dsc_out->bpp = fdsc->bpp; + if(is_tab) dsc_out->box_w = dsc_out->box_w * 2; + return true; }