From a92d41430481342f4071aa54e203df38c33b258e Mon Sep 17 00:00:00 2001 From: Daniel Morais Date: Fri, 31 May 2024 14:04:27 +0200 Subject: [PATCH] Changes related to the code review --- lib_nbgl/src/nbgl_fonts.c | 5 ++++- lib_nbgl/src/nbgl_layout.c | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib_nbgl/src/nbgl_fonts.c b/lib_nbgl/src/nbgl_fonts.c index c3c189637..8c38867d1 100644 --- a/lib_nbgl/src/nbgl_fonts.c +++ b/lib_nbgl/src/nbgl_fonts.c @@ -97,7 +97,9 @@ const unsigned int C_unicode_characters_count uint16_t last_nb_lines = 0; uint16_t last_nb_pages = 0; bool last_bold_state = false; -bool hard_caesura = false; + +// Used to detect when a hyphenation (caesura) has been forced. +bool hard_caesura = false; #endif // BUILD_SCREENSHOTS /********************** @@ -820,6 +822,7 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, } else { #ifdef BUILD_SCREENSHOTS + // An hyphenation (caesura) has been forced. hard_caesura = true; #endif // BUILD_SCREENSHOTS width = char_width; diff --git a/lib_nbgl/src/nbgl_layout.c b/lib_nbgl/src/nbgl_layout.c index 577601b42..c3072bcd8 100644 --- a/lib_nbgl/src/nbgl_layout.c +++ b/lib_nbgl/src/nbgl_layout.c @@ -100,9 +100,6 @@ typedef struct { /********************** * VARIABLES **********************/ -#ifdef BUILD_SCREENSHOTS -extern bool verbose; -#endif // BUILD_SCREENSHOTS /** * @brief array of layouts, if used by modal @@ -2330,18 +2327,15 @@ int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *heade textArea->textAlignment = CENTER; textArea->wrapping = true; // ensure that text fits on 2 lines maximum -#ifdef BUILD_SCREENSHOTS - if (verbose) -#endif // BUILD_SCREENSHOTS - if (nbgl_getTextNbLinesInWidth(textArea->fontId, - textArea->text, - textArea->obj.area.width, - textArea->wrapping) - > 2) { - LOG_WARN(LAYOUT_LOGGER, - "nbgl_layoutAddHeader: text [%s] is too long for header\n", - text); - } + if (nbgl_getTextNbLinesInWidth(textArea->fontId, + textArea->text, + textArea->obj.area.width, + textArea->wrapping) + > 2) { + LOG_WARN(LAYOUT_LOGGER, + "nbgl_layoutAddHeader: text [%s] is too long for header\n", + text); + } layoutInt->headerContainer->children[layoutInt->headerContainer->nbChildren] = (nbgl_obj_t *) textArea; layoutInt->headerContainer->nbChildren++;