mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 15:47:39 +03:00
fix: Clamp page number when out of bounds after font change
When font changes cause different page counts, the cached page number may exceed the new page count. Instead of showing 'Out of bounds' error, clamp to the last page of the section.
This commit is contained in:
parent
c0057900eb
commit
00134bbe80
@ -340,11 +340,11 @@ void EpubReaderActivity::renderScreen() {
|
||||
}
|
||||
|
||||
if (section->currentPage < 0 || section->currentPage >= section->pageCount) {
|
||||
Serial.printf("[%lu] [ERS] Page out of bounds: %d (max %d)\n", millis(), section->currentPage, section->pageCount);
|
||||
renderer.drawCenteredText(UI_12_FONT_ID, 300, "Out of bounds", true, EpdFontFamily::BOLD);
|
||||
renderStatusBar(orientedMarginRight, orientedMarginBottom, orientedMarginLeft);
|
||||
renderer.displayBuffer();
|
||||
return;
|
||||
// Page out of bounds - likely due to font change causing different page count
|
||||
// Clamp to valid range instead of showing error
|
||||
Serial.printf("[%lu] [ERS] Page out of bounds: %d (max %d), clamping to last page\n", millis(),
|
||||
section->currentPage, section->pageCount);
|
||||
section->currentPage = section->pageCount - 1;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user