Repository navigation
Conversation
…ace NFSS selects
Before this, `\verb` and a `verbatim` body were lowered to ordinary
body-face text with an `unsupported_block` limitation saying so ("the
pipeline has no monospaced face or literal-text block"). The compiler had
already tagged them `TextFamily::Mono`, but the pipeline re-derives
`TextStyle.family` from a byte scan of the source for `\ttfamily`/`\texttt`,
and `\verb|x|`'s bytes carry no such command -- so the tag was dropped and
the text came out roman, with `--` turned into an en dash and ``` `` ```
into an opening quote.
This is the `literal` flag of draft PR #145, rebuilt on main's NFSS model
rather than merged. #145 predates `nfss.rs` (its base, 85ec30c, has neither
`nfss.rs` nor `toc.rs`) and carries its own `Role::Mono` + `MonoMetrics`
font-selection model; merging it would put two fields that can disagree
about one fact into the same struct and would revert main's contents lists.
Only its *test material* is reused here. What is taken is the idea; the
mechanism is new.
## The model
`TextStyle` gains `literal: bool`, merged by OR like the other flags and
hashed by the incremental cache. Family selection is unchanged: the
compiler's `TextFamily::Mono` is now routed to `nfss::FamilyKind::Tt` and
everything downstream -- `.fd` shape tables, design-size boundaries,
`ectt`/`ec-lmtt` metrics, `lmmono*` outlines -- is main's existing NFSS
path. There is no second font model.
`literal` changes three things, and deliberately only three:
* **Ligatures.** `Shaper::shape_with(.., literal)` splits the ligature/kern
run before each of `` ` `` `'` `,` `-` `<` `>`. That is exactly where
latex.ltx's `\@noligs` puts its `\kern\z@`, so `--` stays two hyphens and
``` `` ``` two grave accents. #145 shaped literal text one character at a
time; splitting only at `\@noligs`'s six characters is what LaTeX actually
does, and it keeps the ordinary ligatures of a listing set in a roman
`basicstyle` -- the exact case #145 documents as its one mismatch
(`25-lst-java-roman`).
* **Spaces.** A space or tab in literal text becomes `Item::LiteralSpace`,
latex.ltx's `\@xobeysp` = `\leavevmode\nobreak\ `: an empty box one
interword space wide. It cannot be interword glue, because glue after a
line break is discarded (tex.web 879) and a verbatim line's indentation
would vanish with it; and the space must not be *shaped*, because T1 slot
32 of `ectt` is the visible space, not a blank.
* **Hyphenation.** Never, independently of the family (a roman `basicstyle`
listing must not acquire hyphens its source does not have). Protrusion and
expansion need no new rule: microtype's default sets are `rm*`/`sf*`.
Two source-reading fixes fall out:
* `literal_command_body` parses the delimited body of
`\verb`/`\verb*`/`\lstinline` from the source. The compiler's span is the
control word alone, so `|x y|` was being read as the *gap* before the next
token and its space typeset -- `\verb|x y|Z` came out 3.32 pt (one cmr10
space) too wide. `prev_end` now advances past the closing delimiter.
* Verbatim line text and `\verb` bodies are read from the source bytes, not
from the compiler's `verbatim_display` string, which expands a tab to an
8-column stop and renders `\verb*`'s space as U+00B7. LaTeX does neither:
`\@verbatim` sets a tab as one ordinary space, which is why `<tab>one`
starts one typewriter width from the margin in pdfTeX and not eight. That
fixed fixtures 03, 11 and 12 outright. (A compiler-side fix would be
better still, but this crate builds against a pinned vendor mirror.)
## Oracle
`fixtures/verbatim/` is 17 fixtures with pdfLaTeX **MacTeX 2026** references
taken from #145 -- read-only, never regenerated: this host has TeX Live
2025. `tests/verbatim_oracle.rs` matches glyph origins within **0.1 bp**,
requires equal glyph and page counts, and fails on any
`font_unavailable` / `required_metrics_unavailable` / `ec_metrics_unavailable`
/ `font_outline_substituted` diagnostic.
**10 of 17 match pdfLaTeX exactly**, worst 0.006 bp: 01-basic, 02-ligatures,
03-tabs, 04-blank-lines, 07-T1, 08-lmodern, 09-vmode, 11-11pt, 12-12pt,
14-pagebreak (1587 glyphs across a page break). The other 7 are committed
with their references and each listed in `NOT_YET` with the reason it does
not match yet; a second test asserts every fixture on disk is either gated
or listed, so none can be added and quietly left unmeasured.
The test needs the typewriter faces, which arrive with the bundled-fonts PR
(#183). Until then it prints a SKIP naming that dependency rather than
measuring against a substitution. Verified by staging those files in
temporarily: 2 passed, 0 failed, the 10 fixtures listed above.
## Gates
* crates/render-pipeline `cargo test --release`, no FLASHTEX_* exports:
172 passed, 0 failed, 1 ignored (main: 170/0/1; the two new ones are this
oracle).
* amsmath oracle corpus: 59/59 within 0.5 bp.
* real-world corpus (10 fixtures): 204 diagnostics, 0 font-substitution,
every fixture's status and page count identical to main. HW1 3 pages,
HW2 3 pages.
## Not rebuilt from #145, and why
**The listings engine.** #145's `listings.rs` is 1623 lines reimplementing
listings.sty/lstmisc.sty/lstlang1.sty: the key model, the
`\lst@FillFixed`/`\lst@CalcLostSpaceAndOutput` column algorithm, four
language tables, frames, numbers, breaklines. Rebuilding it faithfully is a
body of work in its own right, and none of it can disagree with NFSS until
it exists -- the substrate it needs is `literal` plus typewriter selection,
which is what this change lands. It is not attempted here rather than
half-attempted; the `\lstinline` half is the companion compiler PR.
**`verbatim*` / `\verb*` visible spaces** (fixtures 05, 06). pdfTeX sets
each space as `\char32` of the T1 typewriter font, the `visiblespace` glyph.
The bundled OpenType Latin Modern has no such glyph -- pdfTeX draws it from
the Type 1 ec font -- so this needs a shaper special case *and* a glyph to
draw. `LiteralBody.starred` is parsed and kept for it.
**The `verbatim` environment's `\trivlist` geometry** (fixtures 10, 13, 15):
`\leftskip\@totalleftmargin` inside a list, the overfull box of a too-long
line, and the size declaration in force. Verbatim is still lowered to a
flush-left paragraph with forced breaks; a real verbatim block, which is
what those need, is the natural next step and is what #145 built.
Implementation-Agent: engine-engineer (linux-primary, NixOS PC)
Commit-Executor: engine-engineer via git (Cursor usage limit fallback)
Co-authored-by: GoKubar <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
The compiler's span for a `\verb` is the control word alone on the path that reaches `Inline::Verbatim` (measured: `A \verb|x y|Z` gives span 68..73, the five bytes of `\verb`), while the lexer's own `TokenKind::Verb` span covers the delimiters too. Matching the command name at `span.start` rather than requiring `span.end` to be the end of the control word reads the same delimited body under either convention, so a vendor re-pin cannot silently change which bytes are treated as the body. crates/render-pipeline `cargo test --release --test verbatim_oracle`: 2 passed, 0 failed; the 10 gated fixtures still match pdfLaTeX within 0.006 bp. Implementation-Agent: engine-engineer (linux-primary, NixOS PC) Commit-Executor: engine-engineer via git (Cursor usage limit fallback) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 13, 2026
This was referenced Sep 14, 2026
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.
Based on main
89e49fed, not stacked.crates/render-pipelineonly; no vendor edits, no compiler changes.Companion PRs: #183 (the typewriter fonts this needs to measure against) and
agent/kabir-claude/lstinline-compiler(the\lstinlinehalf).What was wrong
\verband averbatimbody were lowered to ordinary body-face text with anunsupported_blocklimitation saying so ("the pipeline has no monospaced face or literal-text block"). The compiler had already tagged themTextFamily::Mono, but the pipeline re-derivesTextStyle.familyfrom a byte scan of the source for\ttfamily/\texttt, and\verb|x|'s bytes carry no such command — so the tag was dropped, the text came out roman,--became an en dash and``an opening quote.Relationship to draft PR #145
This is #145's
literalflag, rebuilt rather than merged. I confirmed the integrator's reasoning before starting: #145's base85ec30c7has neithernfss.rsnortoc.rs, and its head carries nonfss.rsat all — it has its ownRole::Mono+MonoMetricsfont-selection model (fonts.rs:329,:849,:888). Merging it would put two fields that can disagree about one fact into the same struct and would revert main's contents lists. Only #145's test material is reused. The ideas are taken; the mechanism is new.The model
TextStylegainsliteral: bool, merged by OR like the other flags and hashed by the incremental cache. Family selection is unchanged: the compiler'sTextFamily::Monois now routed tonfss::FamilyKind::Tt, and everything downstream —.fdshape tables, design-size boundaries,ectt/ec-lmttmetrics,lmmono*outlines — is main's existing NFSS path. There is no second font model.literalchanges three things, and deliberately only three:Shaper::shape_withsplits the ligature/kern run before each of`',-<>\@noligsputs its\kern\z@Item::LiteralSpace— an empty box one interword space wide\@xobeysp=\leavevmode\nobreak\; glue after a break is discarded (tex.web §879) and would swallow a verbatim line's indentation, and T1 slot 32 ofecttis the visible space, not a blankbasicstylelisting must not acquire hyphens its source does not haveProtrusion and expansion need no new rule: microtype's default sets are
rm*/sf*.Where this differs from #145 on purpose: #145 shaped literal text one character at a time. Splitting only at
\@noligs's six characters is what LaTeX actually does, and it keeps the ordinary ligatures of a listing set in a romanbasicstyle— the exact case #145 documents as its one unexplained mismatch (25-lst-java-roman).Two source-reading bugs found and fixed
\verb|x y|Zcame out 3.32 pt too wide — onecmr10interword space. The compiler's span for a\verbis the control word alone, so|x y|was read as the gap before the next token and its space typeset.literal_command_bodynow parses the delimited body from the source andprev_endadvances past the closing delimiter. Measured against pdfTeX:Zat 175.190 vs 175.189 after, 178.510 before.verbatim_display, a display string that expands a tab to an 8-column stop and renders\verb*'s space as U+00B7. LaTeX does neither —\@verbatimsets a tab as one ordinary space, which is why<tab>onestarts one typewriter width from the margin in pdfTeX and not eight. Reading the source bytes instead fixed fixtures 03, 11 and 12 outright.Oracle
fixtures/verbatim/is 17 fixtures with pdfLaTeX MacTeX 2026 references taken from #145 — read-only, never regenerated: this host has TeX Live 2025. (Spot-checked: TL 2025 reproduces fixture 07's reference to 0.001 bp, so the two distributions agree on this material.)tests/verbatim_oracle.rsmatches glyph origins within 0.1 bp, requires equal glyph and page counts, and fails on anyfont_unavailable/required_metrics_unavailable/ec_metrics_unavailable/font_outline_substituteddiagnostic.10 of 17 match pdfLaTeX exactly, worst 0.006 bp:
The other 7 are committed with their references and each listed in
NOT_YETwith the reason it does not match; a second test asserts every fixture on disk is either gated or listed, so none can be added and quietly left unmeasured.The test needs the typewriter faces from #183. Until that lands it prints a SKIP naming the dependency rather than measuring against a substitution. The numbers above were produced by staging those files in temporarily.
Gates — control-compared, both font modes
A
git archivecontrol checkout of the shared base89e49fedwas measured the same way, because a globalFLASHTEX_TFM_DIRSbreaks several tests on main that deliberately build a partial-font control (FontSet::newreads the environment, so e.g.missing_required_metrics_are_a_blocking_diagnostic_not_a_silent_fallbackstops failing andmathbb_paints_from_new_computer_modern_when_bundledgets NewCM back).cargo test --release --no-fail-fast:FLASHTEX_*89e49fedThe failing sets are byte-identical (
diffof the sorted names): those 8 are pre-existing and environment-sensitive, not regressions. The two added tests pass in both modes because they never readFLASHTEX_*— they build theirFontSetwithFontSet::with_dirs. That is the durable fix for the 8 as well.Other gates:
Deliberately not rebuilt from #145
listings.rsis 1623 lines reimplementing listings.sty/lstmisc.sty/lstlang1.sty — the key model,\lst@FillFixed/\lst@CalcLostSpaceAndOutput, four language tables, frames, numbers,breaklines. Rebuilding it faithfully is a body of work in its own right, and none of it can disagree with NFSS until it exists. What it needs underneath isliteralplus typewriter selection, which is what this lands. Not attempted rather than half-attempted.verbatim*/\verb*visible spaces (fixtures 05, 06). pdfTeX sets each space as\char32of the T1 typewriter font. The bundled OpenType Latin Modern has novisiblespaceglyph — pdfTeX draws it from the Type 1 ec font — so this needs a shaper special case and a glyph to draw.LiteralBody.starredis parsed and kept for it.verbatimenvironment's\trivlistgeometry (fixtures 10, 13, 15):\leftskip\@totalleftmargininside a list, the overfull box of a too-long line, and the size declaration in force. Verbatim is still lowered to a flush-left paragraph with forced breaks; a real verbatim block is the natural next step and is what render-pipeline: verbatim, verb and listings as LaTeX sets them #145 built.Resume notes
\trivlistglue,\nullempty lines) — that is fixtures 10, 13 and 15 and is the prerequisite for display listings.literal.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu