Repository navigation
fix(theme): keep hard-broken lines at the body line height - #256
Merged
Merged
Conversation
Hard line breaks (`+`, `[%hardbreaks]`, and breaks inside list items) rendered ~2.55pt taller than surrounding lines, so every line but the last in a broken block appeared to sit lower. Asciidoctor converts a hard break into U+000A in the text fragment. Petrona has no glyph for it, so Asciidoctor PDF walks font.fallbacks to find one that does, and Prawn then sizes the whole line by the tallest fragment on it. The copy of M+ 1p in fonts/ does not map U+000A, so the chain fell through to Noto Sans, whose line height at 11pt (14.960) exceeds Petrona-Light's (12.408) by exactly the 2.552pt observed. Point M+ 1p Fallback at the copy bundled with Asciidoctor PDF, which does map U+000A and is shorter than the body font (11.990), so it is selected first and the line height is unchanged. The catalog already uses GEM_FONTS_DIR for the sans-serif family, so this also removes an inconsistency between the two. Verified: hard-broken lines now advance a uniform 13.979pt, matching wrapped lines, and Greek, Cyrillic, Vietnamese, Japanese, arrow replacements, math symbols and smart punctuation still resolve through the fallback chain with no missing-glyph warnings. Fixes riscv/docs-spec-template#118 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Bill Traynor <wmat@riscv.org>
This was referenced Aug 28, 2026
Signed-off-by: Bill Traynor <wmat@riscv.org>
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.
Fixes riscv/docs-spec-template#118
Problem
Hard line breaks render with uneven vertical spacing: every line in a broken block
except the last one appears to sit slightly lower than it should. This affects
+hard breaks,
[%hardbreaks], and hard breaks inside list items (where the bulletappears raised relative to its text).
Measured baseline advances with the current theme at the default 11pt body size:
Root cause
Asciidoctor converts a hard break into a
U+000Acharacter in the text fragment.Petrona has no glyph for
U+000A, so Asciidoctor PDF walksfont.fallbacksto finda font that does, and Prawn then sizes the entire line by the tallest fragment on it.
The copy of M+ 1p in
fonts/does not mapU+000A, so it is skipped despitebeing first in the chain, and the lookup falls through to Noto Sans. At 11pt:
14.960 − 12.408 = 2.552 pt, exactly the excess observed on hard-broken lines.
This is not a Petrona bug — Petrona is simply shorter than the font that ends up
supplying the break glyph. Swapping the body font for a taller one (e.g. Gentium
Plus) masks the symptom without addressing the cause.
Fix
Point the
M+ 1p Fallbackcatalog entry at the copy bundled with Asciidoctor PDF(
GEM_FONTS_DIR/mplus1p-regular-fallback.ttf). That copy does mapU+000Aand isshorter than the body font (11.990), so it is selected first and the line height is
unchanged. The catalog already uses
GEM_FONTS_DIRfor thesans-seriffamily, sothis also removes an inconsistency between the two entries.
Verification
Rebuilt a document exercising
+breaks,[%hardbreaks], breaks inside list items,and broad glyph coverage:
+hard breaks[%hardbreaks]Uniform, and matching wrapped text. Fallback coverage is intact — Greek, Cyrillic,
Vietnamese, Japanese, the
-><-=><=arrow replacements, math symbols andsmart punctuation all still resolve, with no missing-glyph warnings.
🤖 Generated with Claude Code