Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nb_lines computation when multiple pages on nanos #695

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading