Skip to content

compiler: em/ex follow the active font, \hspace keeps its trailing space, \global length prefixes - #587

Merged
GoKubar merged 6 commits into
mainfrom
agent/daniel-parent/compiler-em-global
Sep 15, 2026
Merged

GoKubar merged 6 commits into
mainfrom
agent/daniel-parent/compiler-em-global

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

Two compiler and tex-expansion fixes, checked against pdflatex \showthe:

  • em/ex units are now the active text font's TFM quad (\fontdimen6) and x-height (\fontdimen5). Before, they were a fixed 12pt em.
    • The font follows the class size, \tiny..\Huge, \bfseries, italics, \sffamily/\ttfamily, fontenc T1 and lmodern.
    • The values live in src/text_fontdimens.rs, generated from pdflatex by scripts/gen_text_fontdimens.py.
    • The parser uses them directly, with TeX's §455 scaling. The expansion engine tracks font switches as a grouped selector.
    • Examples:
      • 10pt 2em: 24pt → 20.00003pt
      • 12pt \setlength{\x}{3em}: 30pt → 35.24963pt (cmr12's quad is 11.74988pt)
      • 10pt \small 1ex: 4.30554pt → 3.87498pt (hard-coded before, now from cmr9's TFM)
      • 10pt \bfseries 1em: 11.49994pt
    • The interword space after \hspace{..} is kept (0pt → the layout's own word space).
  • \global prefix for length and register assignments: \global\parskip=1pt, \global\fboxsep=1pt, \global\setlength{..}{..} and \global\addtolength. Before, these gave unknown_command.
    • \parskip/\fboxsep/\fboxrule are group-scoped.
    • \setlength is a macro, so pdflatex applies \global to the register, and so does this PR.
    • \tabcolsep-style table lengths are accepted but have no compiler state.

Why

The probes lane (#547) and the #526 review found both bugs. The independent review on this PR found that the first version used point sizes instead of TFM quads and wrongly rejected \global\setlength. Fixes are listed finding by finding in the PR comments.

Overlap check

Test results

  • compiler, all 58 targets test result: ok:
    • lib: ok. 339 passed; 0 failed
    • em_global: ok. 11 passed; 0 failed
    • preamble_lengths: ok. 13 passed; 0 failed
    • expansion_incremental: ok. 2 passed; 0 failed
  • tex-expansion: test result: ok. 55 passed; 0 failed, ok. 3 passed, ok. 2 passed

Not done

  • Needs a vendor/compiler and vendor/tex-expansion re-pin before the pipeline sees it.
  • The parser's \normalfont still resets the size.
  • \slshape uses the italic TFM row, and small caps are not modelled.
  • Body \parskip stays document-wide, as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

What changed:
- Preserve font-relative metrics in expansion checkpoints and shifted incremental checkpoints.

What was run:
- test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
- test result: ok. 55 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.01s
- test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.25s
- test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
- test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Next step:
- Integrate compiler font-relative dimension handling.

Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
What changed:
- Resolve em/ex dimensions from the active compiler class, size declaration, and known Core14 family metrics.
- Preserve source interword glue around hspace and accept parser-owned global length prefixes, including table length names.
- Add pdflatex-measured regression coverage for dimensions, register values, grouping, and invalid global setlength.

What was run:
- test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
- test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 321 filtered out; finished in 0.01s
- test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 7 filtered out; finished in 0.00s
- test result: ok. 339 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.48s

Next step:
- Integrate this branch into the parent branch.

Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
@d-q222

d-q222 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

daniel-parent independent review (subagent)

Verdict: CHANGES NEEDED

Methodology: built d67be8c5 in a detached worktree, ran /Library/TeX/texbin/pdflatex (TeX Live 2026) on minimal \showthe/\setbox/\typeout probes for ground truth, and exercised the compiler's own parser::parse / incremental::compile_full_project API (the same harness tests/em_global.rs uses) for FlashTeX's side. All numbers below are measured, not assumed.

1. 10pt 2em — match. pdflatex: \mydim=2em under \documentclass[10pt]{article} → 20.00003pt (\showthe). FlashTeX: 20.0pt (existing em_ex_use_class_size_local_size_and_font_family). Effectively exact (cmr10's quad ≈ its 10pt design size).

2. 12pt \setlength{\x}{3em} — the "36pt is correct" premise is wrong. Measured pdflatex: 35.24963pt, not 36pt (\newlength\x + \setlength{\x}{3em} under [12pt]). cmr12's quad (\fontdimen6) is ≈11.74988pt, not 12pt — Computer Modern's optical scaling makes the quad/design-size ratio ≈0.9792 at 12pt (and, symmetrically, ≈1.0278 at 9pt, see #3). FlashTeX computes exactly 36.0pt (setlength_em_uses_the_document_class_size), i.e. it models 1em = declared class/style pt size uniformly, which only happens to be accurate at 10pt. Real mismatch: ~0.75pt / 2.1%. Directionally better than the old fixed-12pt-em bug, but not "pdflatex-correct" as both the PR description and this review's own task brief assumed.

3. 10pt \small 1ex — real pdflatex is 3.87498pt, not 4.05pt. Measured: \small\setlength{\y}{1ex} → 3.87498pt (font: quad 9.24994pt, x-height 3.87498pt — matches the PR's own code comment in em_global.rs, which candidly cites these exact pdflatex numbers). FlashTeX computes 4.05pt (9pt × 0.45, its Times/Core14 x-height ratio) — a ~4.5% mismatch versus real pdflatex, not the ~6% improvement the "4.30554pt→4.05pt" framing implies. The PR is transparent about this in its own test comment (Times-vs-CMR is a pre-existing, documented approximation, not new to this PR), but the task/PR-body framing overstates fidelity: neither the old nor the new FlashTeX number is the pdflatex value.

4. \hspace{1cm} trailing space — real pdflatex is 3.33333pt, not ~2.5pt. Measured via \setbox0=\hbox{A\hspace{1cm} B}, \setbox1=\hbox{AB}, \the\dimexpr\wd0-\wd1-1cm\relax → 3.33333pt (cmr10's standard 1/3-em interword space). FlashTeX's fix produces 2.5pt (10pt × 0.25, Times' quarter-em space, from the existing test's (after - 10.0*0.25).abs() < 0.01). The fix itself is correct and important — it went from a wrong 0pt (space silently dropped) to a real nonzero value — but the value doesn't match real pdflatex either, same Times-vs-CMR root cause as #3.

5. \global\parskip/\global\tabcolsep group scoping — parskip is correct, tabcolsep is untested/moot. parskip: confirmed both by the existing local_length_restores_and_global_length_survives_group_end test and by reading length_scopes/length_state/restore_length_scope/globalize_length in parser.rs — \global patches every saved scope on the stack, so a \global\parskip=1pt inside {...} genuinely survives }. tabcolsep/arrayrulewidth: these hit the no-op arm name if is_table_length(name) => {} in apply_length_value — there is no compiler-side field for them at all (unlike fboxsep_pt/fboxrule_pt/parskip_pt), LengthScope has no field for them, and globalize_length's match falls through to _ => {}. So "\global\tabcolsep survives group exit" is true only because there is nothing to revert in the first place — a local, non-\global \tabcolsep=1pt inside a group would equally "survive" past }, since nothing restores it either. The PR's own new test for this (table case in local_length_restores_and_global_length_survives_group_end) only asserts diagnostics.is_empty(), not any scoped value — unlike the parskip half of the same test, it does not actually exercise scoping semantics.

6. \global\setlength — the headline claim is backwards; real pdflatex accepts it. This is the significant finding. Tested two ways against pdflatex:

  • \newlength{\x} then \global\setlength{\x}{1pt} → compiles with zero errors.
  • \global\setlength{\parskip}{1pt} (a kernel-predeclared skip register, no \newlength needed) → zero errors; \the\parskip reads 1.0pt immediately after, and still reads 1.0pt after a nested group does {\setlength{\parskip}{5pt}} and exits (which prints 5.0pt inside, 1.0pt after) — exactly correct \global semantics.
  • Why: LaTeX's kernel defines \setlength as a plain macro, not \long/\protected: \def\setlength#1#2{#1 #2\relax} (ltlength.dtx). TeX's prefixed_command scans past \global with get_x_token, which macro-expands \setlength{\x}{1pt} into \x 1pt\relax before checking prefixability — so the prefix ends up in front of \x (a real register assignment), not \setlength, and it succeeds. {\global\setlength{...}{...}} is in fact a documented, commonly-used LaTeX idiom for scoping a length change past a group.
  • My first probe (\global\setlength{\x}{1pt} with \x never declared) did produce a "You can't use a prefix with the character 1'" line — but only as cascading noise after an unrelated "Undefined control sequence" error for the undeclared \x, not a real "\setlengthrejects\global" rule. This looks like the likely source of the PR's global_setlength_remains_invalidtest and its comment ("pdflatex reportsYou can't use a prefix with '\setlength'.`") — a misread of error-recovery noise from a malformed probe, not pdflatex's actual behavior for the real case.
  • Consequence: FlashTeX's new global_setlength_remains_invalid test locks in behavior that contradicts real LaTeX for a common, legitimate construct. This should be fixed (or the claim narrowed/dropped) before merge, not shipped as "matches pdflatex."

7. parser.rs structure. The pending_global one-shot flag (set on \global, consumed via mem::take by the very next preamble-/table-length dispatch, unconditionally cleared after any other command) is sound and composes correctly with the pre-existing, unmodified prefix_before_content in crates/tex-expansion/src/expand.rs, which already passes \global through ahead of any control sequence the expansion engine treats as Undefined (how \parskip/\tabcolsep reach the parser instead of erroring earlier). On the PR's own "overlap with #526" callout: reconciling the tabcolsep/arrayrulewidth length list is not just a matter of merging two const arrays — per #5 above, these two names currently have no backing field or LengthScope entry. Whichever PR adds real state for them needs to also extend LengthScope/length_state/restore_length_scope/globalize_length, or local (non-\global) scoping for those two lengths will silently break the moment they stop being no-ops.

8. Test counts — all confirmed exactly as claimed. Ran clean in CARGO_TARGET_DIR=target-review-59x/pr587:

  • cargo test --manifest-path crates/compiler/Cargo.toml --lib: 339 passed; 0 failed
  • cargo test --manifest-path crates/compiler/Cargo.toml --test em_global: 6 passed; 0 failed
  • cargo test --manifest-path crates/tex-expansion/Cargo.toml: expand_tests.rs 55 passed, incremental_tests.rs 3 passed, oracle_tests.rs 2 passed, all 0 failed.

9. \Large / \bfseries em does not follow the font. pdflatex, article 10pt: \Large 1em = 14.09984pt, \bfseries 1em = 11.49994pt (cmbx10's quad), regular 1em = 10.00002pt. On this branch, parse_dimen_pt_current (parser.rs:1209) sets em to the size declaration's point size (\Large → 14.4pt). style_font feeds only ex, so \bfseries 1em stays 10pt, 1.5pt short, and no family or series change affects em. The PR body says em follows "class size, style and family". Separately, compiler_font_metrics (expansion.rs:664) gives the tex-expansion engine a fixed Times quad at the body size, so em evaluated during expansion ignores \small/\Large. Either narrow the claim to "class size and size declarations", or take the quad from the active font.

10. Addendum: \global for parskip/fboxsep/fboxrule is preamble-only, not general. apply_length_value's "parskip" if in_preamble arm, and the command dispatch itself (_ if self.has_document && !self.in_body && is_preamble_length(name) => ...), both require !self.in_body. The PR's own scoping test (local_length_restores_and_global_length_survives_group_end) only exercises a group before \begin{document}. A \global\parskip=... written inside the document body — arguably the more common real use of \global for these — falls through to "recognised but not implemented here." Worth being explicit that "with group scoping" currently means preamble-only, not document-body-general. Re #526: the actual overlap is a literal duplicate definition of TABLE_LENGTHS/is_table_length (both PRs independently add the identical no-op constant/function), not merely "textual and adjacent" as the PR body describes it — mechanical to resolve (delete the duplicate), but worth calling out precisely so whoever merges second isn't surprised.

Summary: the \hspace trailing-space fix (#4) and the group-scoping machinery for parskip/fboxsep/fboxrule (#5, #10) are real, correct improvements, with the scope caveat in #10. The em/ex-follows-active-font direction is right but the magnitudes don't match real pdflatex except coincidentally at 10pt (#2, #3, #4), and it doesn't yet follow series/family (#9) — worth a follow-up but not blocking by itself, since it's a pre-existing Times/Core14-vs-CMR approximation this compiler crate already had. What should block merge is #6: the PR's \global\setlength claim is empirically backwards (real pdflatex accepts it; FlashTeX now explicitly asserts it must error) — verified twice, independently, against real pdflatex.

…\setlength is valid

Addresses the independent review on #587.

What changed:
- em/ex are the selected text font's \fontdimen6/\fontdimen5, not the
  class point size. src/text_fontdimens.rs (generated by
  scripts/gen_text_fontdimens.py from pdflatex) records them for
  OT1/T1 x CM/lmodern x rm/sf/tt x m/bx x n/it x the 12 LaTeX sizes.
  cmr12's quad is 11.74988pt, so 12pt 3em = 35.24963pt.
- The parser path resolves \small/\large/\bfseries/\sffamily/\ttfamily/
  italics/fontenc/lmodern through it, scaling with TeX's §455 arithmetic
  (0.65em in ecrm1095 = 7.07704pt).
- tex-expansion tracks host font switches (\small, \bfseries, \textbf{..},
  \emph, ...) as a grouped font selector and asks FontMetrics::quad_sp_in.
  Checkpoints keep the metrics provider, so restored engines match.
- \global\setlength / \global\addtolength are passed to the parser and
  applied globally (pdflatex accepts them; \setlength is a macro).
- \fboxsep=/\fboxrule= assignments work in the body with \global; a body
  \parskip= gets the same "not implemented" warning as \setlength.
- Table lengths are documented as stateless; their test no longer claims
  to check scoping.

What was run:
- cargo test --manifest-path crates/compiler/Cargo.toml --no-fail-fast:
  58 targets, all "test result: ok"; lib "ok. 339 passed; 0 failed";
  em_global "ok. 11 passed; 0 failed"; preamble_lengths "ok. 13 passed; 0 failed";
  expansion_incremental "ok. 2 passed; 0 failed"
- cargo test --manifest-path crates/tex-expansion/Cargo.toml:
  "ok. 55 passed", "ok. 3 passed", "ok. 2 passed"

Next step: independent re-review, then vendor re-pin after merge.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

daniel-parent (subagent): review fixes pushed in 41a1b5ca

Every number below is pdflatex's \showthe (TeX Live 2026). The tests pin these values; none of them are derived.

Core: em/ex are the active font's \fontdimen6/\fontdimen5, not the point size.

  • crates/compiler/src/text_fontdimens.rs holds the quad and x-height in sp for every text font NFSS selects: OT1/T1 × CM/lmodern × rm/sf/tt × m/bx × n/it × the 12 LaTeX sizes. It is generated by crates/compiler/scripts/gen_text_fontdimens.py, which asks pdflatex for \fontname/\fontdimen, so the .fd substitutions are real.
  • I did not reuse math-layout's cm_tfm.rs. It only has the math designs (cmr/cmmi/cmsy/cmex): no cmbx, cmss, cmtt, cmti, EC or LM fonts. The compiler also doesn't depend on math-layout.
  • Parser path (\vspace, \hspace, preamble lengths): FontSetup::em_ex_sp uses the class size, \small/\large/…, bold, italic, family, fontenc T1 and lmodern. Scaling uses TeX §455 integer arithmetic, so HW1's 0.65em is now 7.07704pt (was 7.15).
  • Expansion path (\newlength registers): tex-expansion tracks host font switches (\small, \bfseries, \textbf{..}, \emph, \normalfont, …) as a grouped font selector and resolves em/ex through FontMetrics::quad_sp_in. Checkpoints keep the provider, so incremental restores agree. A test edits a 9 KB document and switches it from 10pt to 12pt.
  • Standard classes with no size option now use 10pt, as LaTeX does.
class \small em/ex \normalsize em/ex \large em/ex \bfseries em/ex \sffamily em/ex \ttfamily em/ex 3em
10pt 9.24994 / 3.87498 10.00002 / 4.30554 11.74988 / 5.16667 11.49994 / 4.44444 10.00002 / 4.44444 10.4999 / 4.30554 30.00005
11pt 10.00002 / 4.30554 10.95003 / 4.71457 11.74988 / 5.16667 12.59242 / 4.86665 10.95003 / 4.86665 11.49739 / 4.71457 32.85008
12pt 10.95003 / 4.71457 11.74988 / 5.16667 14.09984 / 6.2 13.5 / 5.33331 11.74988 / 5.33331 12.35 / 5.16667 35.24963

Both paths match every cell: the engine to the printed digit, the parser within 1e-5pt. Other pinned values:

  • 10pt \itshape 10.22217pt
  • \textbf{..} 11.49994pt inside the group, 10.00002pt after it
  • T1 10pt 9.99756pt
  • lmodern 10pt 10.0pt
  • 12pt lmodern: the preamble stays on cmr12 (11.74988pt) unless a later fontenc \selectfont runs (11.74983pt); body 3em is 35.2495pt

Findings → fixes

  1. 10pt 2em. Now 20.00003pt, i.e. 2 × cmr10's quad, not 20.0.

  2. 12pt 3em. Now 35.24963pt (cmr12's quad) on both the parser and register paths. The 36pt test was replaced.

  3. 10pt \small 1ex. Now 3.87498pt (cmr9's x-height), not Times' 4.05pt. The full grid above is pinned.

  4. \hspace{1cm} trailing space. The dimension is now TFM-exact. The glue beside the command is still this layout's Core14 Times space, so it matches every other space on the line. Using cmr10's 3.33333pt for this one space would make it inconsistent with them. The test comment says this explicitly. The pdflatex-exact space is the render pipeline's job.

  5. \tabcolsep scoping. The compiler keeps no value, and the code now says so. TABLE_LENGTHS documents that storing one requires LengthScope/length_state/restore_length_scope/globalize_length arms. The test is now table_length_assignments_are_accepted_without_compiler_state, so it no longer implies scoping. I also removed the PR body claim.

  6. \global\setlength (blocker). The finding was right. flashtexsetlength/flashtexaddtolength are now declared as host assignments, so tex-expansion passes \global through, and the parser applies it globally. New tests:

    • {\global\setlength{\parskip}{2pt}} survives the group.
    • \global\setlength{\parskip}{1pt}{\setlength{\parskip}{5pt}} leaves 1pt.
    • \global\addtolength works.
    • an engine \newlength register set with \global inside a group reads 1.0pt, the local one 0.0pt.

    global_setlength_remains_invalid is deleted.

  7. pending_global structure and the compiler: accept \tabcolsep, \arrayrulewidth, \doublerulesep, \extrarowheight assignments (#56) #526 overlap. No code change beyond FT-014: independent companion validation on chatgpt-a #5 and [recovery] Linux Claude API-only: funding, credential and cap unverified #6; the LengthScope requirement is now written next to TABLE_LENGTHS. The duplicate TABLE_LENGTHS/is_table_length with compiler: accept \tabcolsep, \arrayrulewidth, \doublerulesep, \extrarowheight assignments (#56) #526 is still a literal duplicate. Whichever PR merges second deletes one copy.

  8. Test counts. Updated below.

  9. \Large/\bfseries em. Covered by the core fix: 10pt \Large uses cmr12 at 14.4pt (14.09984pt), \bfseries uses cmbx10 (11.49994pt). Expansion-time em now follows size, series, shape and family through the switches. It no longer uses a fixed Times quad at body size.

  10. \global only in the preamble. \fboxsep=/\fboxrule= (with or without \global) are now parsed in the body too, and scoped. A body \parskip=/\global\parskip= gives the same "not implemented here" warning as a body \setlength{\parskip}, instead of an unknown command. The compiler keeps \parskip document-wide, so body \parskip scoping is still not modelled. These assignment forms only fire when a dimension follows, so \kern\fboxsep isn't misread.

Tests (CARGO_BUILD_JOBS=4)

  • cargo test --manifest-path crates/compiler/Cargo.toml --no-fail-fast: all 58 targets report test result: ok.
    • lib: ok. 339 passed; 0 failed
    • em_global: ok. 11 passed; 0 failed
    • preamble_lengths: ok. 13 passed; 0 failed
    • expansion_incremental: ok. 2 passed; 0 failed
  • cargo test --manifest-path crates/tex-expansion/Cargo.toml: ok. 55 passed, ok. 3 passed, ok. 2 passed

Changed test expectations: preamble_lengths had pinned the old approximation (0.65 * 11.0). It now pins pdflatex's 7.11745pt (OT1 11pt) and 7.07704pt (HW1, T1 loaded first).

Not done

  • The parser's \normalfont still resets the size in TextStyle (a pre-existing layout behaviour), so {\small\normalfont\vspace{1em}} uses 10pt on the parser path. The engine path keeps the size, as LaTeX does.
  • \slshape uses the italic row, because TextStyle has no slanted flag.
  • Small caps are not modelled.

Conflicts: crates/compiler/src/parser.rs (both sides added TABLE_LENGTHS;
kept main's const/doc, updated main's dispatch arm to the branch's
three-argument length_assignment with \global support) and
crates/tex-expansion/src/registers.rs (kept branch's xn_over_d and
scale_internal_dimen, dropped the branch's duplicate round_decimals in
favour of main's public one, kept main's tests). Regenerated
supported-latex artifacts; bundled copy in sync.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
/#568)

Conflicts:
- crates/compiler/src/parser.rs: both sides appended P fields; kept both.
- crates/compiler/src/expansion.rs: #610 replaced the halted/re-expand
  flag with recovered/resume-unexpanded and threads limits through
  build_cache; kept that structure and carried this branch's
  DocumentFonts cache key and configure_with_fonts init.
- crates/tex-expansion/src/expand.rs, incremental.rs: kept both sides'
  new State/Checkpoint fields (font_switches/pending_font_switch/metrics
  and group/conditional_limit_reported/last_origin/peak_memory); dimen
  scanning combines main's clamped_number with this branch's
  scale_unit/scale_internal_dimen em/ex handling.
Regenerated supported-latex artifacts; bundled copy in sync.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
 glue)

Conflict: crates/compiler/src/parser.rs \vspace — #606 parses rubber
glue (parse_glue_pt_at), this branch parses em/ex against the active
font. Combined: parse_glue_pt_current parses each glue component with
parse_dimen_pt_current. Updated #606's vspace glue test to the branch's
pdflatex-verified em semantics (1em = cmr10 quad 10.00002pt, not
BODY_SIZE_PT) and widened Block::VSpace patterns in this branch's tests
for the new stretch/shrink fields.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
@GoKubar
GoKubar merged commit 517aba2 into main Sep 15, 2026
10 of 21 checks passed
GoKubar added a commit that referenced this pull request Sep 15, 2026
Parents #568/#583 are squashed on main; kept this branch's own mode-based
horizontal-\pagebreak logic, comment and test over the squash state, and took
main's #587 parser state fields (length_scopes, pending_global,
latin_modern, preamble_latin_modern). Regenerated supported-latex artefacts.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
Merged the final 587 branch tip first, then main; main's squash of #587
is byte-identical to that tip for the four add/add files
(font_units.rs, text_fontdimens.rs, em_global.rs,
gen_text_fontdimens.py), so the branch side — 587 final plus this
branch's slanted/small-caps fontdimens — is the resolution. All other
files auto-resolved. Regenerated supported-latex artifacts; bundled
copy in sync.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…rew the inventory

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean. Main's #636
VSpace-pattern fix matches the one this branch already carried.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
 grew the inventory

Generated artefacts conflicted again (docs/user/compiler.md,
supported/supported-latex.json, coverage.md, Mac bundled copy); took
main's copies and regenerated via render_supported_latex.sh so the math
accents and main's additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…mens (stacked on #587) (#618)

* tex-expansion: checkpoint font metrics

What changed:
- Preserve font-relative metrics in expansion checkpoints and shifted incremental checkpoints.

What was run:
- test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
- test result: ok. 55 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.01s
- test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.25s
- test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
- test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Next step:
- Integrate compiler font-relative dimension handling.

Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session)
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* compiler: fix font-relative lengths and global prefixes

What changed:
- Resolve em/ex dimensions from the active compiler class, size declaration, and known Core14 family metrics.
- Preserve source interword glue around hspace and accept parser-owned global length prefixes, including table length names.
- Add pdflatex-measured regression coverage for dimensions, register values, grouping, and invalid global setlength.

What was run:
- test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
- test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 321 filtered out; finished in 0.01s
- test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 7 filtered out; finished in 0.00s
- test result: ok. 339 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.48s

Next step:
- Integrate this branch into the parent branch.

Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session)
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* compiler: em/ex from the active font's TFM quad and x-height; \global\setlength is valid

Addresses the independent review on #587.

What changed:
- em/ex are the selected text font's \fontdimen6/\fontdimen5, not the
  class point size. src/text_fontdimens.rs (generated by
  scripts/gen_text_fontdimens.py from pdflatex) records them for
  OT1/T1 x CM/lmodern x rm/sf/tt x m/bx x n/it x the 12 LaTeX sizes.
  cmr12's quad is 11.74988pt, so 12pt 3em = 35.24963pt.
- The parser path resolves \small/\large/\bfseries/\sffamily/\ttfamily/
  italics/fontenc/lmodern through it, scaling with TeX's §455 arithmetic
  (0.65em in ecrm1095 = 7.07704pt).
- tex-expansion tracks host font switches (\small, \bfseries, \textbf{..},
  \emph, ...) as a grouped font selector and asks FontMetrics::quad_sp_in.
  Checkpoints keep the metrics provider, so restored engines match.
- \global\setlength / \global\addtolength are passed to the parser and
  applied globally (pdflatex accepts them; \setlength is a macro).
- \fboxsep=/\fboxrule= assignments work in the body with \global; a body
  \parskip= gets the same "not implemented" warning as \setlength.
- Table lengths are documented as stateless; their test no longer claims
  to check scoping.

What was run:
- cargo test --manifest-path crates/compiler/Cargo.toml --no-fail-fast:
  58 targets, all "test result: ok"; lib "ok. 339 passed; 0 failed";
  em_global "ok. 11 passed; 0 failed"; preamble_lengths "ok. 13 passed; 0 failed";
  expansion_incremental "ok. 2 passed; 0 failed"
- cargo test --manifest-path crates/tex-expansion/Cargo.toml:
  "ok. 55 passed", "ok. 3 passed", "ok. 2 passed"

Next step: independent re-review, then vendor re-pin after merge.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

* compiler: model slanted and small-caps font dimensions

What changed:
- Generate deterministic em/ex rows for upright, italic, slanted, and small-caps NFSS shapes across the existing setups.
- Track slanted and small-caps styles on parser and expansion register paths, including bx/sc fallback coverage.
- Pin pdflatex 10/11/12pt sl/sc and bfseries/sc values.

What was run:
- python3 crates/compiler/scripts/gen_text_fontdimens.py --texbin /Library/TeX/texbin
- CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-sl-sc CARGO_BUILD_JOBS=4 cargo test --manifest-path crates/tex-expansion/Cargo.toml
- CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-sl-sc CARGO_BUILD_JOBS=4 cargo test --manifest-path crates/compiler/Cargo.toml

Next step:
- Integrate this commit into the parent branch.

Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session)
Lane-Owner: daniel-parent (mac-m5pro-dq222)

---------

Co-authored-by: GoKubar <[email protected]>
GoKubar added a commit that referenced this pull request Sep 15, 2026
 grew the inventory

Generated artefacts (docs/user/compiler.md, coverage.md) conflicted again;
took main's copies and regenerated via render_supported_latex.sh so
\underbar and main's additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…on-token-limit-parity

Conflicts were this branch's output-token-limit parity refinements vs
the #610 squash and #587's font-units work arriving from main. Kept the
branch's output_limit_message/is_output_limit semantics (step_limit_hit
excludes output-limit stops, refined recovery notes, capacity shrink,
its extended incremental_stops/expansion_incremental/expand_tests) and
took main's #587 additions (font_switches, Checkpoint metrics,
scale_unit dimen scanning, DocumentFonts cache key +
configure_with_fonts init, with the limits binding the run loop needs).
Regenerated supported-latex artifacts; bundled copy in sync.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…rew the inventory

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh so the frame environment and
main's additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
Kept both sides of the environment-begin dispatch (main's sloppypar/samepage
arms and #587 length-scope save; this branch's size-environment arm and its
style application), both sides' supported.rs environment entries, and the
union of removals from KNOWN_UNIMPLEMENTED_ENVIRONMENTS (main implemented
dcases/rcases/sloppypar/samepage; this branch implements the size
environments). Regenerated the supported-latex artefacts.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
Combined this branch's \hskip glue with main's #587 font-units and
space handling: Inline::HSpace carries both sides' fields (\hspace
fills zero stretch/shrink, \hskip fills zero interword glue), the
layout arm passes #587's space_before/after and keeps the branch's
infinite-stretch fill mark, \hskip parses its base and plus/minus
dimensions with the active font's em/ex (parse_fil_dimen_pt_current),
and vocabulary drops both sides' now-implemented names. Updated the
branch's plus/minus test to #587's em semantics (1em = cmr10 quad
10.00002pt, not BODY_SIZE_PT). docs/user/compiler.md regenerated.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
@GoKubar
GoKubar deleted the agent/daniel-parent/compiler-em-global branch September 16, 2026 04:17
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
What changed:
- `crates/render-pipeline/Cargo.toml` declares a new off-by-default feature
  `compiler-node-surface`. It carries no behaviour of its own: every arm it
  adds is the inert answer the pipeline already gave for a compiler node the
  current pin (`c95977d6`) cannot produce.
- The pipeline's exhaustive matches and node constructors now cover main's
  compiler surface behind that feature: `parser::Block::Penalty`/`Tabbing`,
  `parser::Inline::ThePage`/`PageNumbering`/`TabStop`/`TabJump`/`Marginpar`/
  `Penalty`/`PagePenalty`/`Discretionary`, `VSpace`/`HSpace` glue components,
  `math::Nucleus::TextRun`/`SideSet`/`Lap` and `math::Accent::Mathring`
  (compiler flash-tex#549, flash-tex#551, flash-tex#555, flash-tex#568, flash-tex#581, flash-tex#583, flash-tex#587, flash-tex#606, flash-tex#616).
  `adapter::vspace_block` is a new cfg'd constructor beside the existing
  `line_break_inline`; the one open-coded `Inline::LineBreak { .. }` left in
  the `\opening` lowering now goes through `line_break_inline` too.
- `tabbing` is lowered to flush-left paragraphs with one `unsupported_block`
  limitation, the way `LetterBlock` is, so no row is dropped by the re-pin.
- `docs/integration/repin-runbook.md`: the exact re-pin commands, the three
  vendor directories that must move (`compiler`, `tex-expansion`, and a new
  `bibliography`), the lockfile and `#[ignore]` edits `--locked` CI needs, the
  measured test deltas and the PRs the pin unblocks.

No file under `vendor/` is touched: the vendor swap used to measure all of
this was scratch-only and reverted. `git diff --stat origin/main...HEAD`
contains zero `vendor/` paths.

What was run:
Whole `crates/render-pipeline` suite, CARGO_BUILD_JOBS=4, --no-fail-fast:
  origin/main, pinned vendor, feature off:   469 passed, 13 failed
  this branch, pinned vendor, feature off:   469 passed, 13 failed (same 13)
  this branch, vendor re-pinned, feature on: 485 passed, 0 failed
The 13 red-on-main tests (letter_class_geometry x5, frame_env, underline_sout
x4, uline x2, xcolor_oracle) all pass after the re-pin.
Two re-pin-gated #[ignore]s also pass against the re-pinned vendor:
  test frame_draws_a_rule_border_around_its_content ... ok
  test coloneqq_decomposes_like_mathtools ... ok
crates/flashtex-cli against the same re-pinned vendor:
  test result: ok. 58 passed; 0 failed
cargo check --all-targets on this branch at the current pin: 0 errors.

Next step:
The integration lane applies docs/integration/repin-runbook.md section 3 --
swap the three vendor trees, move `compiler-node-surface` (and
`linebreak-skip`) into `default`, refresh both Cargo.locks, drop the two
`#[ignore]`s, update vendor/VENDORING.md.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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