Skip to content

refactor(epub): Japanese CJK line-breaking PR D — ITextMetrics scaffolding + host characterization tests - #4

Merged
mtskf merged 3 commits into
masterfrom
refactor/itextmetrics-scaffolding
Jun 18, 2026
Merged

refactor(epub): Japanese CJK line-breaking PR D — ITextMetrics scaffolding + host characterization tests#4
mtskf merged 3 commits into
masterfrom
refactor/itextmetrics-scaffolding

Conversation

@mtskf

@mtskf mtskf commented Jun 18, 2026

Copy link
Copy Markdown
Owner

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 ParsedText becomes host-testable, then locks down today's English / nbsp / hyphenation / BiDi output so any future regression is caught on the host.

Commits

  1. refactor: extract ITextMetrics and detach TextBlock.h from HAL for host testing
    • New lib/GfxRenderer/ITextMetrics.h: pure-virtual interface with the 7 text-measurement methods ParsedText needs (native-safe — depends only on EpdFontFamily.h).
    • GfxRenderer now implements ITextMetrics (implicit up-cast; identical vtable dispatch — no behavior change).
    • TextBlock.h detached from the HAL: drop #include <HalStorage.h>, forward-declare class HalFile;, move the include into TextBlock.cpp. Adds read-only getWordStyles() / getWordXpos() accessors.
    • ParsedText.{h,cpp} now depend on const ITextMetrics& instead of const GfxRenderer&.
  2. test: host harness pinning current ParsedText layout (English, nbsp, hyphenation, BiDi)
    • test/support/FakeTextMetrics.h: deterministic fixed-width ITextMetrics for 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).
    • CI sentinel gate (.github/workflows/ci.yml) + pre-commit hook (.githooks/pre-commit, appended — preserves the existing clang-format pass) guarding against vacuous placeholder tests.

Verification

  • Host gtest suite green: 4/4 ParsedTextLayout tests pass, pristine under -Wall -Wextra -pedantic.
  • Firmware build is verified by CI (no PlatformIO on the authoring host).
  • Scope is exactly Phase 1; no src/ changes; no cache-format / SECTION_FILE_VERSION bump.

🤖 Generated with Claude Code

@mtskf
mtskf merged commit b30ea6b into master Jun 18, 2026
6 checks passed
@mtskf
mtskf deleted the refactor/itextmetrics-scaffolding branch June 18, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant