Repository navigation
color: answer the questions a drawing package asks about a colour - #8
Merged
Merged
Conversation
A package that draws asks the colour package which model a colour is in, so
it can pick the right device, and asks for a colour's values to hand them to
its driver. This engine keeps colours in RGB rather than xcolor's model
tables, and answered nothing at all — so the first of those names it met
stopped it dead.
That cost more than shadings: \usetikzlibrary{fadings} failed on \XC@sdef,
and a real paper loads its libraries in one breath, so the eight other
libraries listed beside it were lost with it.
The engine now answers, in its own terms: the model is rgb (which is true
here), a colour comes back as {rgb}{values} from the form already published
for every named colour, and a conversion to any model yields those values,
RGB being all there is. A colour that was never defined answers black rather
than swallowing the tokens that followed.
All nine libraries a real arXiv paper asks for — arrows, arrows.meta,
automata, calc, fadings, fit, positioning, shapes, shapes.geometric — now
load, and that paper's first figure draws.
Its bigger figures do not finish: a node with a drawn border takes minutes.
A CPU profile puts about seven tenths of that time in garbage collection,
from the token lists macro expansion copies — the engine's own expansion
machinery, not anything about pictures. Handing the one-token push-backs out
of a shared block was the obvious suspect and measured as no improvement at
all, so it is not in this change; the real work is elsewhere and is worth
doing properly.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Sep 8, 2026
…und (#322) * engine: name the macro whose call a \par abandoned (#315) The runaway alarm counted abandoned calls but never said WHICH macro was being read, so 198 of them over 22 corpus papers were a sum with no handle on it — the same fault #262 repaired for the maths layer, where every dropped formula was filed as "$math$". parEndsArgument now records e.expandingCS, set immediately before the argument scan in getXToken's mMacro case, and Diagnostics carries the tally by name. cmd/gotex prints it under the existing WARNING. Co-Authored-By: Claude Opus 5 <[email protected]> * engine: \@hangfrom must be \long, or every heading is dropped Named by the diagnostic above, \@hangfrom is 179 of the 199 abandoned calls across the 23 corpus documents that have any — 90%, and not a document's malformed macro but our own substrate. 44 of them fall on one paper. Real LaTeX's \@hangfrom takes ONE argument, the label (latex.ltx:12865); the amsart family's second brace group is ordinary material, so the \par that ends it is harmless (mathincs.cls:1177): \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty\@m #8\par} Ours takes that group as #2 — having no hanging indent, it has nothing else to do with it — which makes the \par a runaway, and tex.web §392 abandons the call. The whole heading goes: number and title both. Without the \long prefix the test's page comes out EMPTY. Measured against a control built from the same base: abandoned calls 44→0 on 2401.13343 and 22→0 on 2408.04846, +4649 glyphs, no text lost. Section numbers and whole subsection headings return; I diffed the text layers and every word the diff called lost is still present, reflowed. Five documents each change by a page, so the barometer moves 345→350 and ≤1pp 83→80. Three of the five were ALREADY longer than the reference while missing their headings — 2401.13343 set 30 pages against 29, longer with less content — so restoring the headings adds their height to a body whose excess was being paid for by the loss. The other two shorten, which is page breaking rearranging around a heading, not height. The deficit is now visible instead of cancelled. Co-Authored-By: Claude Opus 5 <[email protected]> * engine: \long the emulation stubs whose real commands are \long The other 20 of the 199 abandoned calls, each checked against the package that defines the real command: \@subfloatopt/\@subfloatnoopt (13) subfig.sty:350,354 are \long \subcaptionbox caption.sty:457 \newcommand (unstarred) and subcaption.sty:270 \long \@titlemand (1) latex.ltx:12747 \DeclareRobustCommand, unstarred, so \long (\@star@or@long, latex.ltx:1173) \@gobbleoptarg (2) \@footnotetext is \long (latex.ltx:13187); array.sty:273 rewrites likewise \@authormand is the deliberate exception and keeps its short form: latex.ltx:12748 declares \author with \DeclareRobustCommand*, and the STARRED branch of \@star@or@long is \relax. A \par in an author block is a runaway in real LaTeX too, so the 3 in the corpus are the documents' error, not ours. A test pins that. \onlinecite (1) is revtex's, not ours. The corpus page barometer does not move: 350 both sides, 27 exact, ≤1pp 80. Five documents change and the raw glyph count falls by 10197 — which is the FIX, not a regression. What disappears is TikZ source that the abandoned call had pushed back and typeset AS TEXT: [] (end) -- (endbot) node[midway, right] \delta; [] (0,0.5) -- (5,0.5) ... What appears is real: sub-caption labels ((b) (c) (d), (m) Bending problem), table rows, and a section counter that was reading 1.1 where the reference has 2.1. A glyph census counts leaked source as content, so stopping a leak reads as loss; the text-layer diff is what settles it. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[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]>
tannevaled
added a commit
that referenced
this pull request
Nov 13, 2026
…ghout (#774) go-typeset/hyphenation v1.0.1 (its #8) fixes an indexing mismatch: the value array was built over the augmented word by BYTE index and read back by RUNE index. The two agree for exactly as long as every letter is one byte — every English word and no French, German, Czech, Polish or Vietnamese one. ⛔ SO EVERY TEST HERE WENT ON PASSING while a whole class of input was set wrong. Nothing in this engine's suite used a multi-byte letter in a word long enough to hyphenate. MEASURED against tectonic 0.17.0, one paragraph at \hsize=72pt, the SAME English patterns on both sides (no babel, no language option): reference Une présenta-/tion … représentations élé-/mentaires … v1.0.0 Une présent-/ation … des représentat-/ions éléme-/ntaires … v1.0.1 Une présenta-/tion … représentations élémentaires … `éléme-ntaires` is the shape of the defect: a break between the m and the n of a syllable, where no pattern in hyphen.tex can put one, and displaced by exactly as many positions as the word has multi-byte letters before it. `présenta-tion` is the one word both engines break in the same place, and v1.0.1 matches the reference there. THE GATE, AND ITS MUTATION accenthyphen_test.go asserts the reference's break and the ABSENCE of the four offset breaks. Its mutation is the dependency itself — pinning go.mod back to v1.0.0 reddens it, which is how the two outputs above were produced, from two builds of this engine differing only in that line: accenthyphen_test.go:48: `présentation` is not broken where the reference breaks it (`présenta-` / `tion`) accenthyphen_test.go:57: the byte/rune offset is back: "éléme-" is in the page ⚠ WHAT THIS DOES NOT CLAIM. The corpus is English-language physics, so the papers that score here barely exercise it; this is not expected to move the fidelity number and no claim is made that it does. It is a defect fixed on its own witness, in a class the metric does not reach — the same shape as #716. Refs go-typeset/hyphenation#8. 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 package that draws asks the color package which model a color is in, to choose its device, and asks it for the color's values to pass them to its driver. This engine keeps colors in RGB rather than in xcolor's model tables, and answered nothing — the first of these names it met stopped it dead.
The cost went beyond gradients:
\usetikzlibrary{fadings}failed on\XC@sdef, and a real paper loads its libraries in one go — the eight others cited alongside it were lost with it.What the engine now answers
rgb(which is true here);{rgb}{values}, taken from the form already published for each named color;Result
The nine libraries a real arXiv paper (LIPIcs, 11 TikZ figures) asks for load:
arrows,arrows.meta,automata,calc,fadings,fit,positioning,shapes,shapes.geometric— and its first figure draws.What does not pass, measured
Its larger figures do not complete: a node with a drawn border takes minutes. A CPU profile puts ~7/10 of the time in garbage collection, caused by the token lists that macro expansion copies — the engine's expansion machinery, nothing specific to figures.
Serving single-token pushbacks from a shared pool was the obvious suspect: measured, no gain (141,712 vs 145,711 ns/op, within the noise). So it is not in this change — the real work is elsewhere and deserves to be done properly.
Verification
go vetandgofmtclean.scripts/fidelity.sh --check: OK.