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,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)