From 2947da180404b758dedd42cb189ffc5734d4daa2 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 4 Sep 2024 22:32:28 +0200 Subject: eve fonts improvement --- fw/fe310/eos/eve/widget/label.c | 2 +- fw/fe310/eos/eve/widget/strw.c | 12 ++++++------ fw/fe310/eos/eve/widget/textw.c | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'fw/fe310/eos/eve/widget') diff --git a/fw/fe310/eos/eve/widget/label.c b/fw/fe310/eos/eve/widget/label.c index bf99051..43c710c 100644 --- a/fw/fe310/eos/eve/widget/label.c +++ b/fw/fe310/eos/eve/widget/label.c @@ -17,7 +17,7 @@ void eve_label_init(EVELabel *label, EVERect *g, EVEFont *font, char *title) { memset(label, 0, sizeof(EVELabel)); if (g) label->g = *g; - rv = eve_font_str_w(font, label->title, &title_w, &title_len); + rv = eve_font_verify(font, label->title, &title_w, &title_len); if (rv) title[title_len] = '\0'; label->font = font; diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c index 873e017..1b2e131 100644 --- a/fw/fe310/eos/eve/widget/strw.c +++ b/fw/fe310/eos/eve/widget/strw.c @@ -34,14 +34,14 @@ void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEFont *fon memset(widget, 0, sizeof(EVEStrWidget)); eve_widget_init(_widget, EVE_WIDGET_TYPE_STR, g, page, eve_strw_draw, eve_strw_touch, eve_strw_putc); - widget->font = font; rv = utf8_verify(str, str_size, &str_len); if (rv) str[str_len] = '\0'; - rv = eve_font_str_w(font, str, &str_w, &str_len); + rv = eve_font_verify(font, str, &str_w, &str_len); if (rv) str[str_len] = '\0'; + widget->font = font; widget->str = str; widget->str_size = str_size; widget->str_len = str_len; @@ -56,7 +56,7 @@ int eve_strw_update(EVEStrWidget *widget) { rv = utf8_verify(widget->str, widget->str_size, &str_len); if (rv) widget->str[str_len] = '\0'; - rv = eve_font_str_w(widget->font, widget->str, &str_w, &str_len); + rv = eve_font_verify(widget->font, widget->str, &str_w, &str_len); if (rv) widget->str[str_len] = '\0'; widget->str_len = str_len; @@ -368,7 +368,7 @@ void eve_strw_putc(void *w, int c) { if (cursor2->on) { del_c = c2->ch - c1->ch; - eve_font_buf_w(widget->font, str, del_c, &del_w, NULL); + del_w = eve_font_buf_w(widget->font, str, del_c); if ((c == CH_CTRLX) || (c == CH_CTRLC)) { eve_clipb_push(str, del_c); if (c == CH_CTRLC) return; @@ -387,8 +387,8 @@ void eve_strw_putc(void *w, int c) { clipb = eve_clipb_get(); if (clipb) { rv = utf8_verify(clipb, EVE_CLIPB_SIZE_BUF, &clipb_len); - if (!rv) rv = eve_font_str_w(widget->font, clipb, &ins_w, NULL); - if (rv) { + if (!rv) ins_w = eve_font_str_w(widget->font, clipb); + if (rv || (ins_w < 0)) { clipb = NULL; clipb_len = 0; ins_w = 0; diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c index f85d1e0..86343a5 100644 --- a/fw/fe310/eos/eve/widget/textw.c +++ b/fw/fe310/eos/eve/widget/textw.c @@ -37,14 +37,14 @@ void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEPage *page, EVEFont *f memset(widget, 0, sizeof(EVETextWidget)); eve_widget_init(_widget, EVE_WIDGET_TYPE_TEXT, g, page, eve_textw_draw, eve_textw_touch, eve_textw_putc); - widget->font = font; rv = utf8_verify(text, text_size, &text_len); if (rv) text[text_len] = '\0'; - rv = eve_font_str_w(font, text, NULL, &text_len); + rv = eve_font_verify(font, text, NULL, &text_len); if (rv) text[text_len] = '\0'; + widget->font = font; widget->text = text; widget->text_size = text_size; widget->text_len = text_len; @@ -59,10 +59,10 @@ int eve_textw_update(EVETextWidget *widget) { int rv; rv = utf8_verify(widget->text, widget->text_size, &text_len); - if (rv != UTF_OK) widget->text[text_len] = '\0'; + if (rv) widget->text[text_len] = '\0'; - rv = eve_font_str_w(widget->font, widget->text, NULL, &text_len); - if (rv != UTF_OK) widget->text[text_len] = '\0'; + rv = eve_font_verify(widget->font, widget->text, NULL, &text_len); + if (rv) widget->text[text_len] = '\0'; memset(widget->line, 0xff, widget->line_size * sizeof(uint16_t)); eve_textw_text_update(widget, 0, 0); @@ -399,8 +399,8 @@ void eve_textw_putc(void *w, int c) { clipb = eve_clipb_get(); if (clipb) { rv = utf8_verify(clipb, EVE_CLIPB_SIZE_BUF, &clipb_len); - if (!rv) rv = eve_font_str_w(widget->font, clipb, &ch_w, NULL); - if (rv) { + if (!rv) ch_w = eve_font_str_w(widget->font, clipb); + if (rv || (ch_w < 0)) { clipb = NULL; clipb_len = 0; ch_w = 0; -- cgit v1.2.3