Add UI font

This commit is contained in:
Dave Allie
2025-12-06 01:37:20 +11:00
parent 248af4b8fb
commit 7198d943b0
13 changed files with 4222 additions and 24 deletions

View File

@@ -10,5 +10,5 @@ void BootLogoScreen::onEnter() {
renderer->clearScreen();
// Location for images is from top right in landscape orientation
renderer->drawImage(CrossLarge, (pageHeight - 128) /2, (pageWidth - 128) / 2, 128, 128);
renderer->drawImage(CrossLarge, (pageHeight - 128) / 2, (pageWidth - 128) / 2, 128, 128);
}

View File

@@ -1,9 +1,8 @@
#pragma once
#include "Screen.h"
class BootLogoScreen final : public Screen {
public:
explicit BootLogoScreen(EpdRenderer* renderer): Screen(renderer) {}
public:
explicit BootLogoScreen(EpdRenderer* renderer) : Screen(renderer) {}
void onEnter() override;
};

View File

@@ -41,10 +41,10 @@ void EpubReaderScreen::onEnter() {
}
void EpubReaderScreen::onExit() {
vTaskDelete(displayTaskHandle);
displayTaskHandle = nullptr;
xSemaphoreTake(sectionMutex, portMAX_DELAY);
vTaskDelete(displayTaskHandle);
vSemaphoreDelete(sectionMutex);
displayTaskHandle = nullptr;
sectionMutex = nullptr;
}

View File

@@ -26,7 +26,10 @@ class EpubReaderScreen final : public Screen {
public:
explicit EpubReaderScreen(EpdRenderer* renderer, Epub* epub, const std::function<void()>& onGoHome)
: Screen(renderer), epub(epub), onGoHome(onGoHome) {}
~EpubReaderScreen() override { free(section); }
~EpubReaderScreen() override {
free(section);
free(epub);
}
void onEnter() override;
void onExit() override;
void handleInput(Input input) override;

View File

@@ -95,14 +95,14 @@ void FileSelectionScreen::render() const {
renderer->drawText((pageWidth - titleWidth) / 2, 0, "CrossPoint Reader", 1, BOLD);
if (files.empty()) {
renderer->drawSmallText(50, 50, "No EPUBs found");
renderer->drawUiText(10, 50, "No EPUBs found");
} else {
// Draw selection
renderer->fillRect(0, 50 + selectorIndex * 20 + 2, pageWidth - 1, 20);
renderer->fillRect(0, 50 + selectorIndex * 30 + 2, pageWidth - 1, 30);
for (size_t i = 0; i < files.size(); i++) {
const auto file = files[i];
renderer->drawSmallText(50, 50 + i * 20, file.c_str(), i == selectorIndex ? 0 : 1);
renderer->drawUiText(10, 50 + i * 30, file.c_str(), i == selectorIndex ? 0 : 1);
}
}

View File

@@ -3,13 +3,12 @@
#include <EpdRenderer.h>
void FullScreenMessageScreen::onEnter() {
const auto width = renderer->getTextWidth(text.c_str(), style);
const auto width = renderer->getUiTextWidth(text.c_str(), style);
const auto height = renderer->getLineHeight();
const auto left = (renderer->getPageWidth() - width) / 2;
const auto top = (renderer->getPageHeight() - height) / 2;
renderer->clearScreen(invert);
renderer->drawText(left, top, text.c_str(), invert ? 0 : 1, style);
// If inverted, do a full screen update to ensure no ghosting
renderer->flushDisplay(!invert);
renderer->drawUiText(left, top, text.c_str(), invert ? 0 : 1, style);
renderer->flushDisplay(partialUpdate);
}

View File

@@ -9,10 +9,11 @@ class FullScreenMessageScreen final : public Screen {
std::string text;
EpdFontStyle style;
bool invert;
bool partialUpdate;
public:
explicit FullScreenMessageScreen(EpdRenderer* renderer, std::string text, const EpdFontStyle style = REGULAR,
const bool invert = false)
: Screen(renderer), text(std::move(text)), style(style), invert(invert) {}
const bool invert = false, const bool partialUpdate = true)
: Screen(renderer), text(std::move(text)), style(style), invert(invert), partialUpdate(partialUpdate) {}
void onEnter() override;
};