Skip to content

render-pipeline: explicit glue keeps the space factor (min-hrulefill 0.554 bp -> 0.004 bp) - #548

Merged
GoKubar merged 1 commit into
mainfrom
agent/daniel-parent/probes-fidelity-space-factor
Sep 15, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/daniel-parent/probes-fidelity-space-factor

Conversation

@d-q222

@d-q222 d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What

Explicit glue no longer resets the space factor. items_from_inlines_styled used to set the factor to 1000 after every HFill, HSpace and TextGlue inline. It now leaves the factor as the last character set it.

Why

TeX sets \spacefactor only when it appends a character, a box in horizontal mode, a rule or math (tex.web §1034-§1044). None of these touch it:

  • glue: \hfill, \quad (\hskip1em\relax) and the \leaders of \hrulefill and \dotfill;
  • the leaders' closing \kern\z@;
  • \leavevmode's \unhbox of a void box.

So in Name: \hrulefill{} Date:, the blank after {} still follows the colon's 2000 and gets \fontdimen7. That is 1.11111 pt in ecrm1000. The two fills share the leftover width, so Date: sat half of that too far left.

  • fixtures/divergence-probes/min-hrulefill: Date: moves 317.276 -> 317.830 bp (pdflatex 317.830). Max delta 0.554 -> 0.004 bp.
  • Name: \dotfill{} Date: \dotfill: 0.282 -> 0.005 bp.
  • Name:\quad{} Date. \quad{} x: 2.217 -> 0.004 bp.

Overlap check

Test results

cargo test --release --test space_factor_after_glue
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
(on origin/main: `Date:` at x 317.276 bp, pdflatex 317.830 bp (off by -0.554 bp))
cargo test --release --no-fail-fast   (whole render-pipeline crate)
80 test binaries: passed 376, failed 0, ignored 3

The test pins the x values pdfLaTeX gives (MacTeX pdfTeX 1.40.29, read with tools/visual-oracle/pdftext.py) for the probe, the \dotfill form and the \quad form. The committed TeX Live 2025 reference agrees at 317.830.

Measured with tools/visual-oracle/rank.py:

  • fixtures/divergence-probes: 1 more word within 0.5 bp (min-hrulefill). No other probe changed.
  • fixtures/real-world: no page changed.

Not done

  • \hspace{<n>em} in a 10 pt article is set at a 12 pt em: +1.99 bp per em (Name\hspace{1em}Date\hspace{2em}x is 5.989 bp off). The blank after \hspace{..}'s argument is also dropped. The em conversion is in crates/compiler (parser.rs "hspace"), so the fix needs a compiler PR and a re-pin. Not attempted here.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

…otfill, \quad)

What changed:
- items_from_inlines_styled no longer resets the space factor to 1000 after
  an HFill/HSpace/TextGlue inline. TeX sets \spacefactor only for characters,
  boxes appended in horizontal mode, rules and math (tex.web §1034-§1044);
  glue, the leaders' closing \kern\z@ and \leavevmode's \unhbox of a void box
  leave it alone. So `Name: \hrulefill{} Date:` keeps the colon's 2000 and
  the blank after `{}` gets \fontdimen7.
- fixtures/divergence-probes/min-hrulefill: `Date:` 317.276 -> 317.830 bp
  (pdflatex 317.830); max delta 0.554 -> 0.004 bp.

What was run:
- cargo test --release --test space_factor_after_glue: test result: ok. 1 passed; 0 failed (fails on origin/main: `Date:` at x 317.276 bp, pdflatex 317.830 bp (off by -0.554 bp))
- cargo test --release --no-fail-fast (whole render-pipeline crate): 80 test binaries, passed 376 failed 0 ignored 3
- tools/visual-oracle/rank.py, fixtures/divergence-probes: within 0.5 bp +1 word (min-hrulefill), no other probe changed
- tools/visual-oracle/rank.py, fixtures/real-world: within 0.5 bp 12277 -> 12277, no page changed
- variants against MacTeX pdflatex: `\dotfill{}` 0.282 -> 0.005 bp, `\quad{}` after `.` 2.217 -> 0.004 bp

Next step: `\hspace{<n>em}` is set at a 12 pt em in a 10 pt article
(+2 bp per em) and the blank after its argument is dropped; not fixed here.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@GoKubar
GoKubar merged commit 45d6862 into main Sep 15, 2026
21 checks passed
GoKubar added a commit that referenced this pull request Sep 15, 2026
…uashed form

#556 refines #547, which has since squash-merged onto main along with five other
render-pipeline landings (#524, #536, #538, #543, #548). Exactly one line
conflicted:

  ours   .map(|(_, e, c, ic)| (*c, *ic && *e == p + 2, *e >= body.len()))
  main   .map(|(_, e, c, _)|  (*c,        *e == p + 2, *e >= body.len()))

The extra `*ic &&` is precisely this PR's change -- it gates the interval on the
fourth field #547 ignores -- so the branch side is kept.

Taking the branch wholesale would have been wrong here. Unlike a plain stacked
rebase, main carries five other commits in this file; git merged those cleanly
around this hunk, and only this one line needed a decision.

Implementation-Agent: orchestrator-astra
Commit-Executor: orchestrator-astra (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
Resolutions:
- typeset.rs: the streaming assembly keeps harvesting math_glyph_unmapped
  in the block loop; main's two new BoxRec variants (Leader, Underline)
  join its span finder. The exact-caret hunk keeps the derived-carets
  Cluster and adopts main's provenance_of.
- display.rs: union — DocumentFeatures (this branch) plus main's
  diagnostic wire caps.
- The \dotfill run from #548 is converted to the derived-caret pattern
  (end_caret on the run), wire-identical through carets_of.
- perf-bench: main's post-#206 canon (recalibrated baseline, product
  assemble signature); the lib/memprofile targets stay.
- main's new tests/examples that read the removed Page.items field now
  use resident_items(); V1 payload accesses are untouched.

Implementation-Agent: fable-ft070
Commit-Executor: fable-ft070 (direct; Cursor usage limit)
@GoKubar
GoKubar deleted the agent/daniel-parent/probes-fidelity-space-factor branch September 16, 2026 04:17
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.

2 participants