Skip to content

fix(epub,font): U+FEFF no-break + setFallback assert symmetry#7

Merged
mtskf merged 4 commits into
masterfrom
fix/cjk-feff-setfallback
Jun 18, 2026
Merged

fix(epub,font): U+FEFF no-break + setFallback assert symmetry#7
mtskf merged 4 commits into
masterfrom
fix/cjk-feff-setfallback

Conversation

@mtskf

@mtskf mtskf commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Two small review follow-ups from the Japanese CJK line-breaking PRs (#4–6). One concern per commit.

FIX 1 — U+FEFF no-break regression (commit 1)

日<U+FEFF>本 was wrapping identically to 日本: the ZWNBSP no-break intent was silently dropped because the trailing CJK base inherited the run's default CjkBreak join. FEFF produces no token, so its only effect is an intrinsic no-break — Utf8ClusterAssembler now sets nextJoin = Glue across it, so the next CJK base stages with Glue. The parser's Feff dispatch keeps discarding the codepoint and no longer touches the join.

Reproduce-first: added host regression test ParserCluster.FeffIsNoBreakBetweenCjk日<FEFF>本 stays glued (Glue) while plain 日本 stays breakable (CjkBreak). Red before the fix, green after.

FIX 2 — setFallback assert symmetry (commit 2)

setFallback asserted only the fallback's glyphMissHandler == nullptr, but resolveGlyph's pointer-identity miss detection runs on the selected primary font too (any of the four, per style). The assert now checks every non-null primary symmetrically, enforcing the already-documented precondition on both sides. Harmless today (UI primaries are static built-ins); a footgun guard for a future ring-buffer-backed primary.

Verification

  • Host gtest: 133/133 pass (cmake --build build/test && ctest), including the new FEFF regression test (red→green observed) and all font-resolver suites.
  • 0 compiler warnings.
  • Firmware pio build + clang-format: left to CI.

mtskf added 4 commits June 18, 2026 16:41
日<U+FEFF>本 previously wrapped identically to 日本 — the ZWNBSP no-break
intent was silently dropped because the trailing CJK base inherited the run's
default CjkBreak join. FEFF (ZWNBSP) produces no token, so its only effect is
an intrinsic no-break: Utf8ClusterAssembler now sets nextJoin = Glue across it,
so the next CJK base stages with Glue instead of CjkBreak. The parser's Feff
dispatch keeps discarding the codepoint and no longer needs to touch the join.

Add a host regression test (ParserCluster.FeffIsNoBreakBetweenCjk): 日<FEFF>本
stays glued (Glue) while plain 日本 stays breakable (CjkBreak). Red before the
fix, green after.
setFallback asserted only the fallback's glyphMissHandler == nullptr, but
resolveGlyph's pointer-identity miss detection runs on the selected primary
font too (any of the four, per style) — not just the fallback. Assert every
non-null primary symmetrically so the already-documented precondition is
structurally enforced on both sides.

Harmless today (the UI primaries that receive a fallback are static built-in
fonts); this is a footgun guard for a future ring-buffer-backed primary.
The prior commit set nextJoin = Glue for every FEFF, which clobbered a
preceding Space (日<space><FEFF>本): the space exists only as the join, so
glueing across the FEFF silently swallowed it (and forbade the break). Guard
the upgrade on nextJoin == CjkBreak, so FEFF only converts a breakable CJK
adjacency into a no-break and leaves a real space — or an already-set Glue —
untouched.

Add ParserCluster.FeffDoesNotSwallowPrecedingSpace, driven from the post-space
state (nextJoin = Space) the parser hands the assembler. Red before the guard,
green after; revert-check confirmed non-vacuous.
The guard added in the prior commit makes the FEFF→Glue upgrade conditional
(only when the adjacency is breakable, nextJoin == CjkBreak), but the
NonCjkKind::Feff doc and the parser's Feff-case comment still read as
unconditional. Correct both to state the assembler upgrades only a breakable
adjacency and leaves a real Space or existing Glue untouched.
@mtskf mtskf merged commit fabafa9 into master Jun 18, 2026
6 checks passed
@mtskf mtskf deleted the fix/cjk-feff-setfallback branch June 18, 2026 07:06
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