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:
@@ -11,7 +11,9 @@ Tracking document for upstream PRs ported into this mod.
|
||||
- [PR #1068](#pr-1068-correct-hyphenation-of-urls) — Correct hyphenation of URLs (Uri-Tauber)
|
||||
- [PR #1329](#pr-1329-refactor-reader-utils) — Refactor shared reader utilities (upstream)
|
||||
- [PR #1143 + #1172](#pr-1143--1172-toc-fragment-navigation--multi-spine-toc) — TOC fragment navigation + multi-spine TOC (upstream)
|
||||
- [PR #1311](#pr-1311-fix-inter-word-spacing-rounding-error) — Fix inter-word spacing rounding error (znelson)
|
||||
- [PR #1320](#pr-1320-jpeg-resource-cleanup) — RAII JPEG resource cleanup (upstream)
|
||||
- [PR #1322](#pr-1322-early-exit-on-filluncompressedsizes) — Early exit on fillUncompressedSizes (jpirnay)
|
||||
- [PR #1325](#pr-1325-settings-tab-label) — Dynamic settings tab label (upstream)
|
||||
|
||||
---
|
||||
@@ -265,8 +267,8 @@ Long URLs in EPUBs could not be line-wrapped because `buildExplicitBreakInfos` r
|
||||
## PR #1329: Refactor reader utils
|
||||
|
||||
- **URL:** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1329](https://github.com/crosspoint-reader/crosspoint-reader/pull/1329)
|
||||
- **Author:** upstream
|
||||
- **Status in upstream:** Open (draft)
|
||||
- **Author:** Uri-Tauber
|
||||
- **Status in upstream:** MERGED (commit `cd508d2`, 2026-03-08). DROP on next sync.
|
||||
- **Method:** Manual port (3 files)
|
||||
|
||||
### Context
|
||||
@@ -356,3 +358,58 @@ The settings screen's "Confirm" button showed a hardcoded "Toggle" label even wh
|
||||
### Differences from upstream PR
|
||||
|
||||
- None -- clean port.
|
||||
|
||||
---
|
||||
|
||||
## PR #1311: Fix inter-word spacing rounding error
|
||||
|
||||
- **URL:** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1311](https://github.com/crosspoint-reader/crosspoint-reader/pull/1311)
|
||||
- **Author:** znelson
|
||||
- **Status in upstream:** Open (approved by jdk2pq, awaiting second review from osteotek)
|
||||
- **Method:** Manual port (4 files)
|
||||
|
||||
### Context
|
||||
|
||||
Inter-word gap widths were computed as two separately-snapped integers: `fp4::toPixel(spaceAdvance) + fp4::toPixel(kernSum)`. Because `fp4::toPixel(a) + fp4::toPixel(b)` can differ from `fp4::toPixel(a + b)` by +/-1 pixel when fractional parts straddle a rounding boundary, each inter-word space could be one pixel wider or narrower than the correct value, affecting line-break width decisions and word-position accumulation.
|
||||
|
||||
### Changes applied
|
||||
|
||||
1. **`lib/GfxRenderer/GfxRenderer.h`**: Replaced `getSpaceKernAdjust()` declaration with `getSpaceAdvance()`, which returns the full inter-word space advance (space glyph advance + both flanking kern values) combined in fixed-point before a single pixel snap.
|
||||
2. **`lib/GfxRenderer/GfxRenderer.cpp`**: Replaced `getSpaceKernAdjust()` implementation with `getSpaceAdvance()` that retrieves the space glyph advance (12.4 FP), adds kern(leftCp, ' ') and kern(' ', rightCp) (4.4 FP), then snaps the combined sum once via `fp4::toPixel()`. `getSpaceWidth()` is retained for the single-space-word case in `measureWordWidth`.
|
||||
3. **`lib/Epub/Epub/ParsedText.h`**: Removed `spaceWidth` parameter from `computeLineBreaks`, `computeHyphenatedLineBreaks`, and `extractLine`.
|
||||
4. **`lib/Epub/Epub/ParsedText.cpp`**: Updated all four call sites (`computeLineBreaks`, `computeHyphenatedLineBreaks`, and both gap-calculation loops in `extractLine`) to use `renderer.getSpaceAdvance()` instead of `spaceWidth + renderer.getSpaceKernAdjust()`. Removed `spaceWidth` pre-computation from `layoutAndExtractLines`.
|
||||
|
||||
### Differences from upstream PR
|
||||
|
||||
- **Mod's vector-based ParsedText**: The mod's `ParsedText.cpp` uses `std::vector` (from #1038 port) and has additional vectors (`forceBreakAfter`, `wordContinues`). The spacing replacement is structurally identical at each call site.
|
||||
- **Word-width cache preserved**: The mod's word-width cache (from #1027 port) is unaffected by this change since it caches `getTextAdvanceX` results, not space widths.
|
||||
|
||||
### Notable PR discussion
|
||||
|
||||
- jdk2pq tested on device and confirmed working.
|
||||
- The single-snap pattern matches what `getTextAdvanceX` already uses for intra-word glyph advances, making inter-word spacing consistent with word-width measurement.
|
||||
|
||||
---
|
||||
|
||||
## PR #1322: Early exit on fillUncompressedSizes
|
||||
|
||||
- **URL:** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1322](https://github.com/crosspoint-reader/crosspoint-reader/pull/1322)
|
||||
- **Author:** jpirnay
|
||||
- **Status in upstream:** MERGED (commit `e60ba76`, 2026-03-08). DROP on next sync.
|
||||
- **Method:** Manual port (1 file)
|
||||
|
||||
### Context
|
||||
|
||||
`fillUncompressedSizes` scanned the entire ZIP central directory even when all requested target entries had already been matched, wasting time on large EPUB files with many entries.
|
||||
|
||||
### Changes applied
|
||||
|
||||
1. **`lib/ZipFile/ZipFile.cpp`**: Added `targetCount` variable before the scan loop and a `break` after the inner match loop when `matched >= targetCount`, terminating the central-directory scan early.
|
||||
|
||||
### Differences from upstream PR
|
||||
|
||||
- None -- identical to upstream commit `e60ba76`.
|
||||
|
||||
### Notable PR discussion
|
||||
|
||||
- CodeRabbit flagged a theoretical duplicate-match overcount issue, but znelson and ngxson approved as-is since duplicate central-directory filenames are not expected in valid EPUB/ZIP files.
|
||||
|
||||
Reference in New Issue
Block a user