Skip to content

render: paint the \not slash across the relation, not in the space before it - #295

Merged
GoKubar merged 1 commit into
mainfrom
agent/linux-not-slash/render-paint
Sep 15, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/linux-not-slash/render-paint

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

render: paint the \not slash across the relation, not in the space before it

Owner report: "\ne and \neq don't work." They are both in the tables and
both render; what was wrong was where the negation stroke is painted.

\not (fontmath.ltx 432: \mathchardef\not="3236, cmsy "36) is a
zero-width overprint: TeX sets the slash in an empty box and the relation
that follows it draws on top. The advances were already exact -- but the
painting face draws that slash at U+0338, and U+0338 is a Unicode
combining mark, which composes with the character before it. Latin
Modern Math therefore puts its ink entirely to the LEFT of its own origin,
x in [-4.58, -0.69] pt at 10 pt (hmtx lsb -458, CFF xMax -69 of 1000 upm).
Painted at TeX's box origin the stroke landed in the thickmuskip in front of
the relation, 1.25 pt of clear air short of where the ='s ink begins,
so $a \ne b$ drew a slash floating in the gap and an untouched =.

The slash is now kerned onto the relation's painted ink centre. That is the
rule the amssymb negated sentinels in this same function already used (that
branch is refactored onto the shared ink_centre helper, no behaviour
change), and it is what this face's own precomposed negations look like:
Latin Modern Math's U+2260/U+2209/U+2270 ink boxes are exactly their base
relation's, with the stroke drawn inside.

No box moves. The slash still advances zero and the relation keeps its
TFM width.

Measured against pdflatex TL2025 (pdfTeX 3.141592653-2.6-1.40.27), 10 pt
article, \hbox{$...$} width, bundled apps/mac/Fonts, zero font-FAILURE
diagnostics. Widths are unchanged by this commit -- they were already right,
which is the point:

box pdflatex FlashTeX (before = after)
$=$ 7.77780 7.77800
$\neq$ 7.77780 7.77800
$\ne$ 7.77780 7.77800
$a=b$ 22.91077 22.91096
$a \ne b$ 22.91077 22.91096
$a \neq b$ 22.91077 22.91096
$\in$ / $\notin$ 6.66669 6.66669
$a \notin b$ 21.79965 21.79965
$x^{\neq}$ (script) 12.35419 12.35428
$x^{y^{\neq}}$ (scriptscript) 16.16100 16.16103

The +0.0002 pt is the display list's bp tick, identical on the = control.
Script and scriptscript are reached with superscripts, the way a document
reaches them; the \scriptstyle/\scriptscriptstyle switches are ignored
by this engine ($\scriptstyle=$ 7.77800 against pdflatex's 6.13892, and
$\scriptstyle\neq$ is off by the identical 1.63908 pt), which is a separate
pre-existing gap, not a \ne one.

What the commit does change, $a \neq b$ at 10 pt, absolute page x in pt:

before after the = it must strike
slash ink (138.857, 142.747) (145.377, 149.267) ink (143.997, 150.657)

Before, the stroke ended 1.25 pt before the equals sign started. After, its
ink centre is the equals sign's to 0.005 pt. \notin likewise.

New the_negation_slash_is_painted_across_the_relation_it_negates asserts
the slash's ink lies inside the negated relation's and shares its centre, for
\neq, \ne and \notin; on origin/main it fails with
the slash's ink (75.990, 80.641) bp is not inside the '=' it negates (82.111, 89.918).

symbol_atoms also gains an arm mapping a bare U+0338 to one Rel atom, for
the \not row added to the compiler's table in the sibling PR
(math-layout's default_class would otherwise make the combining character
Ord and open a thick space in front of the relation). It is inert against the
current vendor/compiler pin, which has no \not row -- that pin needs a
re-pin past the compiler PR before \not<rel> reaches the CLI or the Mac
app
; no vendor file is touched here. Verified end-to-end with a throwaway
local vendor copy (reverted, never committed): with both halves in place
$\not=$, $\not<$, $\not\in$ and $\not\subset$ measure 7.77800,
7.77780, 6.66669 and 7.77780 against pdflatex's 7.77780, 7.77780, 6.66669
and 7.77780, and the \not is not supported in math mode error is gone.

Heights are deliberately not read from hit_rect: a math cluster's
hit_rect takes width from the TeX box and height from the painted ink, so
it cannot be read as "the glyph's box". Everything above is advance and CFF
ink-box geometry.

Gates, NixOS linux-primary, bundled apps/mac/Fonts, FLASHTEX_TFM_DIRS =
public/lm:jknappen/ec:public/amsfonts/symbols, CARGO_BUILD_JOBS=4. Zero
font-FAILURE diagnostics (font_unavailable, required_metrics_unavailable,
ec_metrics_unavailable, font_outline_substituted, tfm_missing,
math_font_unavailable) everywhere:

gate control (origin/main) this branch
render-pipeline suite 213 passed, 0 failed 214 passed, 0 failed
math-layout suite 66 passed, 0 failed 66 passed, 0 failed (untouched)
compiler suite 485 passed, 0 failed 485 passed, 0 failed (untouched)
amsmath corpus 59/59 within 0.5 bp 59/59
amssymb corpus 38/39 (32-braces-narrow) 38/39 (same one)
HW1 / HW2 3 pages, 0 errors, 0 overfull same
real-world corpus (22 fixtures) status/pages/diagnostic sets identical to control

Five corpus fixtures (hw2, inline-math, math-sheet, ps-calculus,
twelvept-plain) contain \ne/\neq, so the repaint is exercised on real
documents and moves no word. The corpus ran --no-oracle --no-pixels: this
machine has neither MacTeX nor a rasteriser, so that comparison is
status/pages/diagnostics, not pixels.

Implementation-Agent: Claude Opus 5 (engine lane, linux-primary / NixOS)
Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution
under the observed-Cursor-limit user override)
Co-Authored-By: Claude Opus 5 [email protected]
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…before it

Owner report: "`\ne` and `\neq` don't work." They are both in the tables and
both render; what was wrong was **where the negation stroke is painted**.

`\not` (`fontmath.ltx` 432: `\mathchardef\not="3236`, cmsy `"36`) is a
zero-width overprint: TeX sets the slash in an empty box and the relation
that *follows* it draws on top. The advances were already exact -- but the
painting face draws that slash at U+0338, and U+0338 is a Unicode
**combining** mark, which composes with the character *before* it. Latin
Modern Math therefore puts its ink entirely to the LEFT of its own origin,
x in [-4.58, -0.69] pt at 10 pt (`hmtx` lsb -458, CFF xMax -69 of 1000 upm).
Painted at TeX's box origin the stroke landed in the thickmuskip in front of
the relation, **1.25 pt of clear air short of where the `=`'s ink begins**,
so `$a \ne b$` drew a slash floating in the gap and an untouched `=`.

The slash is now kerned onto the relation's painted ink centre. That is the
rule the amssymb negated sentinels in this same function already used (that
branch is refactored onto the shared `ink_centre` helper, no behaviour
change), and it is what this face's own precomposed negations look like:
Latin Modern Math's U+2260/U+2209/U+2270 ink boxes are exactly their base
relation's, with the stroke drawn inside.

**No box moves.** The slash still advances zero and the relation keeps its
TFM width.

Measured against pdflatex TL2025 (pdfTeX 3.141592653-2.6-1.40.27), 10 pt
article, `\hbox{$...$}` width, bundled `apps/mac/Fonts`, zero font-FAILURE
diagnostics. Widths are unchanged by this commit -- they were already right,
which is the point:

| box | pdflatex | FlashTeX (before = after) |
|---|---:|---:|
| `$=$` | 7.77780 | 7.77800 |
| `$\neq$` | 7.77780 | 7.77800 |
| `$\ne$` | 7.77780 | 7.77800 |
| `$a=b$` | 22.91077 | 22.91096 |
| `$a \ne b$` | 22.91077 | 22.91096 |
| `$a \neq b$` | 22.91077 | 22.91096 |
| `$\in$` / `$\notin$` | 6.66669 | 6.66669 |
| `$a \notin b$` | 21.79965 | 21.79965 |
| `$x^{\neq}$` (script) | 12.35419 | 12.35428 |
| `$x^{y^{\neq}}$` (scriptscript) | 16.16100 | 16.16103 |

The +0.0002 pt is the display list's bp tick, identical on the `=` control.
Script and scriptscript are reached with superscripts, the way a document
reaches them; the `\scriptstyle`/`\scriptscriptstyle` *switches* are ignored
by this engine (`$\scriptstyle=$` 7.77800 against pdflatex's 6.13892, and
`$\scriptstyle\neq$` is off by the identical 1.63908 pt), which is a separate
pre-existing gap, not a `\ne` one.

What the commit does change, `$a \neq b$` at 10 pt, absolute page x in pt:

| | before | after | the `=` it must strike |
|---|---:|---:|---|
| slash ink | (138.857, 142.747) | (145.377, 149.267) | ink (143.997, 150.657) |

Before, the stroke ended 1.25 pt before the equals sign started. After, its
ink centre is the equals sign's to 0.005 pt. `\notin` likewise.

New `the_negation_slash_is_painted_across_the_relation_it_negates` asserts
the slash's ink lies inside the negated relation's and shares its centre, for
`\neq`, `\ne` and `\notin`; on `origin/main` it fails with
`the slash's ink (75.990, 80.641) bp is not inside the '=' it negates
(82.111, 89.918)`.

`symbol_atoms` also gains an arm mapping a bare U+0338 to one Rel atom, for
the `\not` row added to the compiler's table in the sibling PR
(math-layout's `default_class` would otherwise make the combining character
Ord and open a thick space in front of the relation). It is inert against the
current `vendor/compiler` pin, which has no `\not` row -- **that pin needs a
re-pin past the compiler PR before `\not<rel>` reaches the CLI or the Mac
app**; no vendor file is touched here. Verified end-to-end with a throwaway
local vendor copy (reverted, never committed): with both halves in place
`$\not=$`, `$\not<$`, `$\not\in$` and `$\not\subset$` measure 7.77800,
7.77780, 6.66669 and 7.77780 against pdflatex's 7.77780, 7.77780, 6.66669
and 7.77780, and the `\not is not supported in math mode` error is gone.

Heights are deliberately not read from `hit_rect`: a math cluster's
`hit_rect` takes width from the TeX box and height from the painted ink, so
it cannot be read as "the glyph's box". Everything above is advance and CFF
ink-box geometry.

Gates, NixOS linux-primary, bundled `apps/mac/Fonts`, `FLASHTEX_TFM_DIRS` =
`public/lm:jknappen/ec:public/amsfonts/symbols`, `CARGO_BUILD_JOBS=4`. Zero
font-FAILURE diagnostics (`font_unavailable`, `required_metrics_unavailable`,
`ec_metrics_unavailable`, `font_outline_substituted`, `tfm_missing`,
`math_font_unavailable`) everywhere:

| gate | control (origin/main) | this branch |
|---|---|---|
| render-pipeline suite | 213 passed, 0 failed | 214 passed, 0 failed |
| math-layout suite | 66 passed, 0 failed | 66 passed, 0 failed (untouched) |
| compiler suite | 485 passed, 0 failed | 485 passed, 0 failed (untouched) |
| amsmath corpus | 59/59 within 0.5 bp | 59/59 |
| amssymb corpus | 38/39 (`32-braces-narrow`) | 38/39 (same one) |
| HW1 / HW2 | 3 pages, 0 errors, 0 overfull | same |
| real-world corpus (22 fixtures) | status/pages/diagnostic sets | identical to control |

Five corpus fixtures (`hw2`, `inline-math`, `math-sheet`, `ps-calculus`,
`twelvept-plain`) contain `\ne`/`\neq`, so the repaint is exercised on real
documents and moves no word. The corpus ran `--no-oracle --no-pixels`: this
machine has neither MacTeX nor a rasteriser, so that comparison is
status/pages/diagnostics, not pixels.

Implementation-Agent: Claude Opus 5 (engine lane, linux-primary / NixOS)
Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution
under the observed-Cursor-limit user override)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar force-pushed the agent/linux-not-slash/render-paint branch from c9fcae2 to a511630 Compare September 15, 2026 22:13
@GoKubar
GoKubar marked this pull request as ready for review September 15, 2026 22:14
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (`2d1b5176`) and re-verified on linux-primary.

The conflict was stale-only. `typeset.rs` (the fix) auto-merged; only `tests/math_symbols.rs` conflicted, because main added `positioned_math_glyphs` and this branch added `glyph_ink_x` at the same point. Both are independent additive helpers, so main's file was taken and this branch's 85 added lines re-spliced at the same anchor — no behaviour change to either side.

Negative control (the part that matters). Same tree, only `src/typeset.rs` reverted to main's:

test the_negation_slash_is_painted_across_the_relation_it_negates ... FAILED
$a \neq b$: the slash's ink (75.990, 80.641) bp is not inside the '=' it negates (82.111, 89.918)

The slash's ink ends at 80.641 bp; the equals sign's ink begins at 82.111 bp — a 1.47 bp gap. That is the owner-reported "`\ne` renders as `/=`", reproduced as a number: the stroke is painted in the thick space in front of the relation, not across it. With the fix, the test passes.

This PR alone fixes the owner-visible defect. `\ne`/`\neq` already reach the pipeline as U+2260 through the vendored compiler and are decomposed into the two atoms there; only the paint position was wrong. Sibling #296 (`\not` as an inventory entry) is a separate bug — `$\not=$` still errors — and it stays inert for the app until `crates/render-pipeline/vendor/compiler` is re-pinned, as its own body states. So these can land independently and #295 should not wait on the vendor re-pin.

Gates: render-pipeline suite green, bundled `apps/mac/Fonts`, `FLASHTEX_TFM_DIRS` = `public/lm:jknappen/ec:public/amsfonts/symbols`. The `unused import: FontSet` warning at `math_symbols.rs:950` is pre-existing (main's line 865 + this branch's 85-line insertion).

@GoKubar
GoKubar merged commit ec3cb67 into main Sep 15, 2026
20 of 22 checks passed
@GoKubar
GoKubar deleted the agent/linux-not-slash/render-paint branch September 15, 2026 22:35
GoKubar added a commit that referenced this pull request Sep 15, 2026
GoKubar added a commit that referenced this pull request Sep 15, 2026
GoKubar added a commit that referenced this pull request Sep 15, 2026
GoKubar added a commit that referenced this pull request Sep 15, 2026
…ests only) (#668)

The output-identity gate is a hard fail, and main itself has been failing
it: the committed digests predate #295/#296 (negated relations) and #649
(list label and item-text geometry, /ActualText groups), so every PR
touching layout tripped a gate that main could not pass either.

Re-recorded on the reference host at main 35ead1c over the full 26-case
corpus. 14 cases move, 116 digest values in all; 12 are byte-identical,
including both synthetic documents and math-heavy/tikz-heavy.

ONLY the per-case `digests` maps change. `meta`, `targets`, every
per-case `metrics` map and `load1_max` are byte-identical to #206's
capture, verified field by field -- no timing number here is claimed to
have been measured on this host, and none has been replaced.

Attribution, by re-recording at 44b21ad (main immediately before #649)
and diffing both ways:

  pre-#649 (#295 \ne paint position, #296 \not as a zero-width
  \mathrel): hw2, inline-math, math-sheet, ps-calculus, twelvept-plain
  -- every corpus document containing \ne, \neq or \not, which is two
  more than a \ne-only grep finds.

  #649 (#611/#625/#628 list label and item-text offsets; #614
  /ActualText): cv, enumitem-worksheet, hyperref-toc, lab-report,
  lecture-notes, listings-manual, lmodern-report, plain-article,
  ps-calculus, thesis-chapter, twelvept-plain.

The changed set is exactly the documents using itemize/description or a
negated relation. hw1 is unchanged and uses only enumerate, which the
list work did not move; lecture-notes changed only its export.pdf and v2
keys, from #614 grouping the \gcd/\lcm multi-glyph runs.

Digests are independent of --runs: a control at --runs 5 (CI's setting)
over hw1, math-sheet and plain-article reproduces the --runs 1 digests
exactly.

Gate after the re-record, at main, full corpus: 601 metrics compared, no
digest change, exit 0.


Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

Co-authored-by: Claude Opus 5 <[email protected]>
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.

1 participant