engine: make the font-size commands \tiny…\Huge functional again - #76
Open
tannevaled wants to merge 1 commit into
Open
engine: make the font-size commands \tiny…\Huge functional again#76tannevaled wants to merge 1 commit into
tannevaled wants to merge 1 commit into
Conversation
A size clo (size10/size11/size12.clo) redefines \normalsize, \small, …, \Huge
as \@setfontsize\<cmd>\<size>{<leading>}, and the engine's \@setfontsize is a
no-op gobble — so after the class loaded, EVERY size command was dead. A heading
set with \Large, a caption with \small, a footnote with \footnotesize all came
out at the body size, with the body leading: wrong glyph size AND wrong vertical
space on essentially every document (proven: at 10/11/12pt every command sat at
the base size with the base \baselineskip).
Revive them the way #75 handled \normalsize — through the FONT SYSTEM, not by
making \@setfontsize a live primitive. At \begin{document} (\AtBeginDocument),
\gotex@sizeclosetup reads the (size, leading) the ACTIVE clo baked into each
command's body and redefines the command as a \protected macro
\gotexsize<permille>\relax\gotexleading<leading>sp\relax <clo tail>
where \gotexsize scales the class base font (as \large already did) to the clo's
absolute point size, \gotexleading sets the matching \baselineskip (a new
primitive, group-scoped via a new save-stack entry), and the clo's own tail — the
\abovedisplayskip / \belowdisplayskip glue and \@Listi list parameters that
\small/\footnotesize carry — is preserved, since the dead gobble left it running.
Reading the values off the active clo gives each class its own table, so \Large
in a 12pt document is the 12pt clo's 17pt on 22pt leading, not the 10pt one.
Marking the macro \protected is what keeps it robust in a moving context — a
section title flowing into the ToC, a caption into the LoF — exactly the failure
mode #75 avoided by refusing to make \@setfontsize functional. \normalsize is
deliberately left as the dead gobble: #75 owns the base size and leading, and
\normalsize is called on nearly every reset, so hardcoding a \baselineskip into
it would fight a document's own \linespread/setspace and densify everything.
Per-command proof (glyph size / \baselineskip), matching the clo byte-for-byte:
10pt tiny 5/6 scriptsize 7/8 footnotesize 8/9.5 small 9/11
large 12/14 Large 14/18 LARGE 17/22 huge 20/25 Huge 25/30
11pt … small 10/12 large 12/14 Large 14/18 huge 20/25 Huge 25/30
12pt … small 11/13.6 large 14/18 Large 17/22 LARGE 20/25 huge/Huge 25/30
Layout impact is MIXED, not a clear win. On the -layout harness (40 papers, seed
1, tectonic ground truth) the mean divergence moves 7.760 -> 8.377 and the total
page-count error 123 -> 133 — a net REGRESSION driven almost entirely by ONE
algorithm2e paper (2508.20008, whose \SetCommentSty is only partly supported):
excluding it the mean improves 7.929 -> 7.879. Heading-heavy papers gain (one
13.76 -> 6.29), while caption/footnote/small-heavy papers lose a little, because
the engine already packs denser than tectonic and correct sizing amplifies that
pre-existing line-break/page-build divergence. This lands the correctness fix;
the layout metric will reward it once dense-region breaking matches tectonic.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What was broken
A size clo (
size10/size11/size12.clo) redefines\normalsize,\small, …,\Hugeas\@setfontsize\<cmd>\<size>{<leading>}, and the engine's\@setfontsizeis a no-op gobble. So after the class loaded, every size command was dead — a heading set with\Large, a caption with\small, a footnote with\footnotesizeall rendered at the body size with the body leading. Measured before this change, every command sat at the base size with the base\baselineskipat 10pt, 11pt and 12pt.The fix
Same route as #75 (which revived
\normalsize's base size): drive the size through the font system, not by making\@setfontsizea live primitive. At\begin{document},\gotex@sizeclosetupreads the(size, leading)the active clo baked into each command's body and redefines it as a\protectedmacro:\gotexsizescales the class base font (as\largealready did) to the clo's absolute point size.\gotexleading(new primitive) sets the matching\baselineskip, group-scoped via a new save-stack entry.\abovedisplayskip/\belowdisplayskipglue and\@listiparams that\small/\footnotesizecarry — is preserved (the dead gobble left it running).\protectedkeeps it robust in a moving context (a section title into the ToC, a caption into the LoF) — exactly the failure mode engine: honour a class's 11pt/12pt base size in the font system #75 avoided by refusing to make\@setfontsizefunctional.\Largein a 12pt document is the 12pt clo's 17pt on 22pt leading.\normalsizeis deliberately not rewired (engine: honour a class's 11pt/12pt base size in the font system #75 owns its base size/leading; it is called on nearly every reset, so hardcoding a leading would fight\linespread/setspace).Per-command proof (glyph size /
\baselineskip), matches the clo byte-for-byteLayout impact — MIXED, not a clear win (please review before merging)
On the
-layoutharness (40 papers, seed 1, tectonic ground truth):The aggregate is a net regression, driven almost entirely by one algorithm2e paper (
2508.20008, whose\SetCommentStyis only partly supported): excluding that single outlier the mean improves 7.929 → 7.879. Heading-heavy papers gain (one2608.07597: 13.76 → 6.29); caption/footnote/\small-heavy papers lose a little, because the engine already packs denser than tectonic and correct sizing amplifies that pre-existing line-break/page-build divergence. Counts: 3 improved (2 large), 7 slightly worsened, 18 unchanged.This is a correctness fix (the commands were genuinely dead); the layout metric should reward it once dense-region breaking matches tectonic more closely. Opening for review, not merging.
Verification
go test -race ./...green; conformance / faithfulness gates green;gofmt/go vetclean.fontsizeclo.go,doLeading) at 100% statement coverage incl. error branches.\normalsize/base-size behaviour unchanged.🤖 Generated with Claude Code