Skip to content

Commit

Permalink
Merge pull request #682 from LedgerHQ/fix_nblines
Browse files Browse the repository at this point in the history
Fix nb_lines computation when multiple pages on nanos
  • Loading branch information
dmorais-ledger committed Jun 6, 2024
2 parents d51bc0a + c9417b6 commit cc14f18
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions lib_nbgl/src/nbgl_fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,27 +753,22 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
// if \f, exit loop
if (unicode == '\f') {
#ifdef BUILD_SCREENSHOTS
++last_nb_pages;
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
if (textLen) {
++last_nb_pages;
}
#endif // BUILD_SCREENSHOTS
break;
}
// if \n, increment the number of lines
else if (unicode == '\n') {
nbLines++;
#ifdef BUILD_SCREENSHOTS
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
#ifdef SCREEN_SIZE_NANO
if (nbLines == 4) {
++last_nb_pages;
nbLines = 0;
#if defined(BUILD_SCREENSHOTS) && defined(SCREEN_SIZE_NANO)
if (!(nbLines % 4)) {
if (textLen) {
++last_nb_pages;
}
}
#endif // SCREEN_SIZE_NANO
#endif // BUILD_SCREENSHOTS
#endif // defined(BUILD_SCREENSHOTS) && defined(SCREEN_SIZE_NANO)
width = 0;
lastDelimiter = NULL;
continue;
Expand Down Expand Up @@ -828,17 +823,13 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
width = char_width;
}
nbLines++;
#ifdef BUILD_SCREENSHOTS
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
#ifdef SCREEN_SIZE_NANO
if (nbLines == 4) {
++last_nb_pages;
nbLines = 0;
#if defined(BUILD_SCREENSHOTS) && defined(SCREEN_SIZE_NANO)
if (!(nbLines % 4)) {
if (textLen) {
++last_nb_pages;
}
}
#endif // SCREEN_SIZE_NANO
#endif // BUILD_SCREENSHOTS
#endif // defined(BUILD_SCREENSHOTS) && defined(SCREEN_SIZE_NANO)
}
else {
width += char_width;
Expand All @@ -848,12 +839,10 @@ uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId,
if (width != 0) {
++nbLines;
}
#endif // SCREEN_SIZE_NANO
#ifdef BUILD_SCREENSHOTS
if (last_nb_lines < nbLines) {
last_nb_lines = nbLines;
}
last_nb_lines = nbLines;
#endif // BUILD_SCREENSHOTS
#endif // SCREEN_SIZE_NANO
return nbLines;
}

Expand Down

0 comments on commit cc14f18

Please sign in to comment.