fix: resolve mod build errors after upstream sync
- Update open-x4-sdk submodule to 9f76376 (BatteryMonitor ESP-IDF 5.x compat) - Add RTC_NOINIT bounds check for logHead in Logging.cpp - Add drawTextRotated90CCW to GfxRenderer for dictionary UI - Add getWordXpos() accessor to TextBlock for dictionary word selection - Fix bare include paths (ActivityResult.h, RenderLock.h) across 10 files - Fix rvalue ref binding in setResult() lambdas (std::move pattern) - Fix std::max type mismatch (uint8_t vs int) in EpubReaderActivity - Fix FsFile forward declaration conflict in Dictionary.h - Restore StringUtils::checkFileExtension() and sortFileList() - Restore RecentBooksStore::removeBook() Made-with: Cursor
This commit is contained in:
@@ -61,7 +61,7 @@ static inline void rotateCoordinates(const GfxRenderer::Orientation orientation,
|
||||
}
|
||||
}
|
||||
|
||||
enum class TextRotation { None, Rotated90CW };
|
||||
enum class TextRotation { None, Rotated90CW, Rotated90CCW };
|
||||
|
||||
// Shared glyph rendering logic for normal and rotated text.
|
||||
// Coordinate mapping and cursor advance direction are selected at compile time via the template parameter.
|
||||
@@ -91,6 +91,9 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
|
||||
if constexpr (rotation == TextRotation::Rotated90CW) {
|
||||
outerBase = cursorX + fontData->ascender - top; // screenX = outerBase + glyphY
|
||||
innerBase = cursorY - left; // screenY = innerBase - glyphX
|
||||
} else if constexpr (rotation == TextRotation::Rotated90CCW) {
|
||||
outerBase = cursorX + fontData->advanceY - 1 - fontData->ascender + top; // screenX = outerBase - glyphY
|
||||
innerBase = cursorY + left; // screenY = innerBase + glyphX
|
||||
} else {
|
||||
outerBase = cursorY - top; // screenY = outerBase + glyphY
|
||||
innerBase = cursorX + left; // screenX = innerBase + glyphX
|
||||
@@ -99,12 +102,16 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
|
||||
if (is2Bit) {
|
||||
int pixelPosition = 0;
|
||||
for (int glyphY = 0; glyphY < height; glyphY++) {
|
||||
const int outerCoord = outerBase + glyphY;
|
||||
const int outerCoord =
|
||||
(rotation == TextRotation::Rotated90CCW) ? outerBase - glyphY : outerBase + glyphY;
|
||||
for (int glyphX = 0; glyphX < width; glyphX++, pixelPosition++) {
|
||||
int screenX, screenY;
|
||||
if constexpr (rotation == TextRotation::Rotated90CW) {
|
||||
screenX = outerCoord;
|
||||
screenY = innerBase - glyphX;
|
||||
} else if constexpr (rotation == TextRotation::Rotated90CCW) {
|
||||
screenX = outerCoord;
|
||||
screenY = innerBase + glyphX;
|
||||
} else {
|
||||
screenX = innerBase + glyphX;
|
||||
screenY = outerCoord;
|
||||
@@ -133,12 +140,16 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
|
||||
} else {
|
||||
int pixelPosition = 0;
|
||||
for (int glyphY = 0; glyphY < height; glyphY++) {
|
||||
const int outerCoord = outerBase + glyphY;
|
||||
const int outerCoord =
|
||||
(rotation == TextRotation::Rotated90CCW) ? outerBase - glyphY : outerBase + glyphY;
|
||||
for (int glyphX = 0; glyphX < width; glyphX++, pixelPosition++) {
|
||||
int screenX, screenY;
|
||||
if constexpr (rotation == TextRotation::Rotated90CW) {
|
||||
screenX = outerCoord;
|
||||
screenY = innerBase - glyphX;
|
||||
} else if constexpr (rotation == TextRotation::Rotated90CCW) {
|
||||
screenX = outerCoord;
|
||||
screenY = innerBase + glyphX;
|
||||
} else {
|
||||
screenX = innerBase + glyphX;
|
||||
screenY = outerCoord;
|
||||
@@ -1243,6 +1254,64 @@ void GfxRenderer::drawTextRotated90CW(const int fontId, const int x, const int y
|
||||
}
|
||||
}
|
||||
|
||||
void GfxRenderer::drawTextRotated90CCW(const int fontId, const int x, const int y, const char* text, const bool black,
|
||||
const EpdFontFamily::Style style) const {
|
||||
if (text == nullptr || *text == '\0') {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto fontIt = fontMap.find(fontId);
|
||||
if (fontIt == fontMap.end()) {
|
||||
LOG_ERR("GFX", "Font %d not found", fontId);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& font = fontIt->second;
|
||||
|
||||
int32_t yPosFP = fp4::fromPixel(y);
|
||||
int lastBaseY = y;
|
||||
int lastBaseAdvanceFP = 0;
|
||||
int lastBaseTop = 0;
|
||||
constexpr int MIN_COMBINING_GAP_PX = 1;
|
||||
|
||||
uint32_t cp;
|
||||
uint32_t prevCp = 0;
|
||||
while ((cp = utf8NextCodepoint(reinterpret_cast<const uint8_t**>(&text)))) {
|
||||
if (utf8IsCombiningMark(cp)) {
|
||||
const EpdGlyph* combiningGlyph = font.getGlyph(cp, style);
|
||||
int raiseBy = 0;
|
||||
if (combiningGlyph) {
|
||||
const int currentGap = combiningGlyph->top - combiningGlyph->height - lastBaseTop;
|
||||
if (currentGap < MIN_COMBINING_GAP_PX) {
|
||||
raiseBy = MIN_COMBINING_GAP_PX - currentGap;
|
||||
}
|
||||
}
|
||||
|
||||
const int combiningX = x + raiseBy;
|
||||
const int combiningY = lastBaseY + fp4::toPixel(lastBaseAdvanceFP / 2);
|
||||
renderCharImpl<TextRotation::Rotated90CCW>(*this, renderMode, font, cp, combiningX, combiningY, black, style);
|
||||
continue;
|
||||
}
|
||||
|
||||
cp = font.applyLigatures(cp, text, style);
|
||||
if (prevCp != 0) {
|
||||
yPosFP += font.getKerning(prevCp, cp, style); // add for CCW (opposite of CW)
|
||||
}
|
||||
|
||||
lastBaseY = fp4::toPixel(yPosFP);
|
||||
const EpdGlyph* glyph = font.getGlyph(cp, style);
|
||||
|
||||
lastBaseAdvanceFP = glyph ? glyph->advanceX : 0;
|
||||
lastBaseTop = glyph ? glyph->top : 0;
|
||||
|
||||
renderCharImpl<TextRotation::Rotated90CCW>(*this, renderMode, font, cp, x, lastBaseY, black, style);
|
||||
if (glyph) {
|
||||
yPosFP += glyph->advanceX; // add for CCW (opposite of CW)
|
||||
}
|
||||
prevCp = cp;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* GfxRenderer::getFrameBuffer() const { return frameBuffer; }
|
||||
|
||||
size_t GfxRenderer::getBufferSize() { return HalDisplay::BUFFER_SIZE; }
|
||||
|
||||
Reference in New Issue
Block a user