Skip to content

fix(api): TOC dot leaders sit on the entry baseline, not the top#246

Merged
DemchaAV merged 4 commits into
developfrom
fix/toc-leader-baseline
Jun 26, 2026
Merged

fix(api): TOC dot leaders sit on the entry baseline, not the top#246
DemchaAV merged 4 commits into
developfrom
fix/toc-leader-baseline

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

addTableOfContents(...) rendered each entry row with the default TOP cross-axis alignment, so the thin dotted leader line rode along the top of the text instead of the baseline where a dot leader belongs:

Chapter One ⠁⠁⠁⠁⠁⠁⠁ 3 ← dots at the cap line (before)
Chapter One ……………… 3 ← dots on the baseline (after)

What changed

One line in TocBuilder.buildEntryRow: the entry row is now verticalAlign(BOTTOM), so the leader, the label, and the page number share the baseline. Output-only — no public API surface changes.

Verification

  • TocBuilderTest — new test asserts the entry row is bottom-aligned (RowNode.verticalAlign() == BOTTOM); the existing blank-label/anchor guards still pass.
  • TocTest / PageReferenceTest (text + clickable GoTo targets) unchanged and green.
  • ./mvnw test -pl . — green, 0 changed snapshot baselines (the TOC is not pixel-snapshotted; the change is purely the leader's Y). japicmp + javadoc clean.
  • Rendered TocExample and refreshed its committed assets/readme/examples/table-of-contents.pdf preview — leaders now sit on the baseline.

DemchaAV and others added 4 commits June 26, 2026 23:18
addTableOfContents(...) laid each entry row with the default TOP cross-axis
alignment, so the thin leader line rode along the top of the text instead of the
baseline where a dot leader belongs. Bottom-align the entry row so the leader, the
label, and the page number share the baseline.

Tests: TocBuilderTest asserts the entry row is bottom-aligned. Output-only change
(no API surface, no snapshot baselines affected); the committed table-of-contents
preview is refreshed.
Bottom-aligning the entry row dropped the thin leader line to the descender line,
below the baseline the label and page number sit on. Lift the leader by about the
font's descent (proportional to the entry size) so the dots are level with the text
and the number. Committed table-of-contents preview refreshed.
Name the magic 0.2 leader-lift factor (LEADER_BASELINE_LIFT_RATIO) and document
that it is a deliberate approximation of the font descent, which is not reachable
from the DSL layer, and that it assumes the entry and page-number styles share a
size. Add a test asserting the leader carries a positive bottom margin — bottom
alignment alone leaves it on the descender line, so the lift is the behaviour to
pin.
@DemchaAV DemchaAV merged commit 1080bde into develop Jun 26, 2026
11 checks passed
@DemchaAV DemchaAV deleted the fix/toc-leader-baseline branch June 26, 2026 23:05
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