Repository navigation
engine: \selectfont brings the font back, and \voidb@x exists - #6
Merged
Merged
Conversation
\selectfont installs the font the current family, series and shape call for.
The engine defined it as doing nothing.
That matters because of what it is used for: a package switches to \nullfont
around material it wants measured but not set, and brings the real font back
with \selectfont. With \selectfont inert the font never came back, so
everything typeset afterwards was set in a font with no characters at all.
pgf does this for every picture — which is why a TikZ node's text box came
out empty, and its letters were lost.
This engine keeps one text face per family rather than NFSS's tables, so
\selectfont re-selects the base (roman, \normalsize) face; the switch is
scoped like any other, so a group restores what was in force before it.
\voidb@x, the kernel's permanently empty box, was missing too.
\setbox<n>=\box\voidb@x is how a package empties a register, and without the
name that idiom read register 0 instead and stole whatever was in it.
A node's text now composes and is placed where it belongs: \node at (1.5,1)
{Bonjour}; in a 3-by-2 rectangle comes out centred on the rectangle, verified
by rendering the SVG. In PDF the letters still land at the picture's origin —
there the glyphs are drawn by the text driver, outside the transform scopes
the vector stream carries, which is a separate thing to fix.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Oct 18, 2026
…s style group (#621) Two errors of opposite sign that were cancelling each other, which is why the visible symptom was a quarter of either one. 1ex WAS HALF THE FONT SIZE. TeX takes it from \fontdimen5 — tex.web §455 ("The x-height for cur_font" → x_height(cur_font)) and §10675 ("param[5]=x_height is the size of one ex in the font"). Measured against the reference at 10pt in Latin Modern: before after reference 1ex 5.0pt 4.31pt 4.31pt 1em 10.0pt 10.0pt 10.0pt 3.5ex 17.5pt 15.08499 15.08499 2.3ex 11.5pt 9.913pt 9.913pt 16% too big, on every dimension a class states in ex — and classes state a great many. article's \section alone is \@startsection{section}{1}{\z@}{-3.5ex plus -1ex minus -.2ex}{2.3ex plus .2ex} so each heading took 4.00pt more vertical space than the reference gives it. AND THE HEADING'S \par RAN OUTSIDE ITS STYLE GROUP, where LaTeX's \@SecT puts it inside: \begingroup #6\relax … #8\@@Par \endgroup. The heading's last line therefore ended under the BODY's \baselineskip instead of the heading's, worth −5.978pt per heading. −5.978 + 4.00 = −1.98, and the symptom that started this was 1.99pt per section. Fixing either alone makes headings WORSE than leaving both; together they land on the reference. Three witnesses, each measured between two words of the same type size so poppler's word-box bias (a constant 1.41 ratio between engines) cancels: witness before after reference article's \section 52.804 54.795 54.793 \@startsection, rigid skips 48.791 54.769 54.767 \@startsection, article's 52.804 54.795 54.793 All three within 0.002pt. HOW ex IS OBTAINED, in TeX's order of authority: an ASSIGNED \fontdimen5 if the document wrote one, as extraSpaceOf already honours \fontdimen7; otherwise the height of the glyph 'x' in that face, which is what the x-height IS and keeps this to the fontFace interface the engine already has; and only with no font at all, half the size — the old approximation, kept for the one case it was right for. A face whose 'x' has zero height falls back rather than returning 0, since a 0pt ex would collapse every ex-stated skip in the document. Seven tests. TestEmExUnits changes: it asserted 1ex = 5.0pt, half the size, which is the defect. spMock reports 7pt for every glyph, so its 'x' is 7pt and the new expectation discriminates — half the size would still be 5.0pt. ⚠ The \par placement is asserted by the SHAPE of the kernel definition, which is weaker than asserting behaviour and is deliberate: its effect is a 5.978pt shift that only the oracle resolves, and mutate showed that moving the brace back survives every other test here. The TeX property it relies on — a \par inside a group takes that group's \baselineskip — is tested on its own. Co-authored-by: Claude Opus 5 <[email protected]>
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.
A TikZ node's text typesets and positions correctly.
The cause
\selectfontinstalls the font that the current family, weight and shape call for. The engine defined it as doing nothing.What matters is how it is used: a package switches to
\nullfontaround material it wants to measure without typesetting, then restores the real font with\selectfont. With\selectfontinert, the font never came back — everything that followed was typeset in a font with no characters at all. pgf does this for every figure: hence a node's empty text box and its lost letters.This engine keeps one font per family rather than the NFSS tables, so
\selectfontre-selects the base font (roman,\normalsize); the change is carried by a group like any other.\voidb@x, the kernel's permanent empty box, was also missing:\setbox<n>=\box\voidb@xis how a package empties a register, and without that name the idiom read register 0 and stole its contents.Result
\node at (1.5,1) {Bonjour};inside a 3×2 rectangle comes out centered on the rectangle — verified by rendering the SVG (rsvg-convert), andpdftotextreads the whole word.In PDF the letters still land at the figure's origin: there the glyphs are drawn by the text driver, outside the transformation scopes that the vector stream carries. This is a separate point, noted for later.
Verification
go vetandgofmtclean.scripts/fidelity.sh --check: OK.\pgfsys@hboxsynced): with this fix the SVG placement is already correct, and the two variants stay indistinguishable on this case — I do not ship what I cannot prove.