fix(api): TOC dot leaders sit on the entry baseline, not the top#246
Merged
Conversation
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.
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.
Why
addTableOfContents(...)rendered each entry row with the defaultTOPcross-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 nowverticalAlign(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.TocExampleand refreshed its committedassets/readme/examples/table-of-contents.pdfpreview — leaders now sit on the baseline.