port: upstream PRs #1311 (inter-word spacing fix) and #1322 (zip early exit)

PR #1311: Replace separate spaceWidth + getSpaceKernAdjust() with a
single getSpaceAdvance() that combines space glyph advance and kerning
in fixed-point before snapping to pixels, eliminating +/-1 px rounding
drift in text layout.

PR #1322: Add early exit to fillUncompressedSizes() once all target
entries are matched, avoiding unnecessary central directory traversal.

Also updates tracking docs and verifies PR #1329 (reader utils refactor)
matches upstream after merge.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-08 15:53:13 -04:00
parent 0d8a3fdbdd
commit 255b98bda0
9 changed files with 167 additions and 37 deletions

View File

@@ -0,0 +1,28 @@
# Restore Preferred Orientation Settings and Long-Press Sub-Menu
**Date**: 2026-03-08
**Branch**: mod/master
**Commit**: 0d8a3fd
## Task
Restore two orientation preference features lost during the upstream PR resync:
1. Settings UI entries for preferred portrait/landscape modes
2. Long-press sub-menu on the reader menu's orientation toggle
## Changes
### Settings UI and Persistence
- **`src/SettingsList.h`**: Added `DynamicEnum` entries for `preferredPortrait` (Portrait/Inverted) and `preferredLandscape` (Landscape CW/Landscape CCW) in the Reader settings category. Uses getter/setter lambdas to map between sequential indices and non-sequential orientation enum values.
- **`src/JsonSettingsIO.cpp`**: Added manual JSON save/load for both fields with validation (rejects invalid orientation values, falls back to defaults).
### Long-Press Orientation Sub-Menu
- **`src/activities/reader/EpubReaderMenuActivity.h`**: Added `orientationSubMenuOpen`, `orientationSubMenuIndex`, and `ignoreNextConfirmRelease` state flags.
- **`src/activities/reader/EpubReaderMenuActivity.cpp`**:
- `loop()`: Long-press (700ms) on Confirm when the orientation item is selected opens the sub-menu. Sub-menu handles its own Up/Down/Confirm/Back input. Added `ignoreNextConfirmRelease` guard to prevent the long-press release from immediately selecting.
- `render()`: When sub-menu is open, renders a centered list of all 4 orientations with the current one marked with `*`. Uses the same gutter/hint layout as the main menu.
## Follow-up
- Hardware testing needed for both features
- Translations for `STR_PREFERRED_PORTRAIT` and `STR_PREFERRED_LANDSCAPE` only exist in English; other languages fall back automatically

View File

@@ -0,0 +1,43 @@
# Port Upstream PRs #1311, #1322 + Verify #1329
**Date:** 2026-03-08
**Task:** Port two upstream PRs and verify alignment of a previously-ported PR that was recently merged.
## Changes Made
### PR #1311 -- Fix inter-word spacing rounding error (UNMERGED, ported as mod feature)
Replaced `getSpaceKernAdjust()` with `getSpaceAdvance()` which combines space glyph advance and flanking kern values into a single fixed-point sum before pixel snapping, fixing +/-1 px rounding drift in inter-word spacing.
**Files modified:**
- `lib/GfxRenderer/GfxRenderer.h` -- replaced declaration
- `lib/GfxRenderer/GfxRenderer.cpp` -- replaced implementation (single-snap pattern)
- `lib/Epub/Epub/ParsedText.h` -- removed `spaceWidth` parameter from 3 internal functions
- `lib/Epub/Epub/ParsedText.cpp` -- updated all 4 call sites to use `getSpaceAdvance()`
### PR #1322 -- Early exit on fillUncompressedSizes (MERGED, ported for immediate use)
Added `targetCount` variable and early `break` when all ZIP central-directory targets are matched.
**Files modified:**
- `lib/ZipFile/ZipFile.cpp` -- 5-line addition
### PR #1329 -- Reader utils refactor (MERGED, verification only)
Confirmed our existing port matches the upstream merged version (commit `cd508d2`) line-for-line. No code changes needed.
### Tracking documentation updated
- `mod/docs/upstream-sync.md` -- added #1311, #1322; updated #1329 status to MERGED
- `mod/prs/MERGED.md` -- added detailed entries for #1311 and #1322; updated #1329 author and status
## Build Result
SUCCESS -- zero compiler errors/warnings from our changes. Only pre-existing i18n translation warnings.
## Follow-up Items
- #1311: Will be dropped during next sync if/when merged upstream
- #1322: Will be dropped during next sync (already merged upstream)
- #1329: Will be dropped during next sync (already merged upstream)
- Hardware testing recommended: verify text layout rendering after spacing fix (#1311)