refactor(epub): Japanese CJK line-breaking PR D — ITextMetrics scaffolding + host characterization tests - #4
Merged
Conversation
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Japanese / CJK Line-Breaking — PR D (Phase 1: Testability Scaffolding)
First PR of the Japanese CJK line-breaking effort. Behavior-preserving refactor: it makes the text-layout code host-testable and pins the current layout behavior with characterization tests. No layout behavior changes (English or Japanese).
Why
The eventual fix (later PRs) generalises the word-join model so CJK paragraphs wrap at the page edge. Before touching layout, this PR extracts a thin text-metrics interface so
ParsedTextbecomes host-testable, then locks down today's English / nbsp / hyphenation / BiDi output so any future regression is caught on the host.Commits
refactor: extract ITextMetrics and detach TextBlock.h from HAL for host testinglib/GfxRenderer/ITextMetrics.h: pure-virtual interface with the 7 text-measurement methodsParsedTextneeds (native-safe — depends only onEpdFontFamily.h).GfxRenderernow implementsITextMetrics(implicit up-cast; identical vtable dispatch — no behavior change).TextBlock.hdetached from the HAL: drop#include <HalStorage.h>, forward-declareclass HalFile;, move the include intoTextBlock.cpp. Adds read-onlygetWordStyles()/getWordXpos()accessors.ParsedText.{h,cpp}now depend onconst ITextMetrics&instead ofconst GfxRenderer&.test: host harness pinning current ParsedText layout (English, nbsp, hyphenation, BiDi)test/support/FakeTextMetrics.h: deterministic fixed-widthITextMetricsfor host tests.test/parsed_text/ParsedTextLayoutTest.cpp: 4 characterization tests pinning current break behavior (English word-wrap, no-break-space glue, Liang hyphenation split, BiDi RTL reorder)..github/workflows/ci.yml) + pre-commit hook (.githooks/pre-commit, appended — preserves the existing clang-format pass) guarding against vacuous placeholder tests.Verification
ParsedTextLayouttests pass, pristine under-Wall -Wextra -pedantic.src/changes; no cache-format /SECTION_FILE_VERSIONbump.🤖 Generated with Claude Code