You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The fidelity metric cannot see a kerning defect: 1.12pt per AV was invisible to every number we steer by #716
The kerning defect fixed in go-opentype/opentype#63 (and adopted in #715) made every AV in LibertinusSerif 1.12pt too wide at 10pt — \hbox{AV} measured 13.47pt against XeTeX's 12.35pt, because no kern was applied at all.
Every number we steer by was blind to it.
go test ./...: green throughout, before and after.
sweeppair + labeldiff on the two clean-list papers that load libertinus (2311.02037, 2407.19892): "aucun document n'a bougé entre les deux étiquettes" — while both PDFs changed byte-wise.
Σ, bias and the exact count: unchanged.
The reason is structural, not a gap in the corpus. The routine score is word recall plus line breaks, and a kern moves glyphs within a line: the same words break at the same points, so nothing the metric counts moves. A font could lose its kerning entirely and the dashboard would not flicker.
It was found with \setbox0=\hbox{AV}\showthe\wd0 run on both engines, which is the only probe we have that sees inside a line.
What would see it
gotex-refdiff -layout already ranks papers by how far matched words drift, which is exactly the quantity a kern changes. It is not what the routine sweep runs.
Worth deciding between:
A box-metric conformance test: a small set of pairs (AV, To, VA, AW, Pa) measured with \showthe\wd0 against values taken from XeTeX, per bundled font. Cheap, deterministic, no corpus, and it fails the moment a font's kerning stops arriving. It also needs an oracle run only once per font.
A layout pass in the sweep, so intra-line drift is part of the routine number rather than a separate tool nobody runs.
(1) is the one that would have caught this, in milliseconds, without the corpus. (2) is the one that generalises to the next thing the word metric cannot see.
I lean to (1) first, since it is the control the fix itself lacked: go-opentype#63's own regression test is a synthetic fixture, and the real-font check that confirmed it lives in a scratch directory rather than in either repository.
Correcting the framing of my own report, because it was too broad.
I wrote that "the fidelity metric cannot see a kerning defect". That is accurate for score and labeldiff, which compare page counts, and it is not accurate for the harness as a whole. hashdiff already hashes the rendered page and reports the ink delta per document, and it ends its own output with:
20 document(s) comparable(s); 19 ont un rendu DIFFÉRENT, dont 9 à nombre de pages identique
⛔ ces 9-là sont INVISIBLES pour labeldiff et pour score, qui ne comparent que les pages
So the tool for this class of defect exists, knows what it is for, and says so. What is missing is narrower and more fixable than what I filed: the routine sweep does not run it, so the number anyone quotes — Σ, bias, exact — still comes from the page metric alone.
That changes the proposal. Running hashdiff beside labeldiff in the routine path would have shown the kerning change on the two libertinus papers immediately, with no new code at all. The per-font box-metric test (proposal 1) is still worth having, because it localises a metric defect to a font and a pair instead of reporting that a page hash moved — but it is a second line of defence, not the first one.
Demonstrated on #703 in the meantime: with the package reachable, 19 of 20 papers render differently and 9 of them keep the same page count, so nine real changes would have been reported as "aucun document n'a bougé" by the metric we steer by.
⭐ A SECOND INSTANCE TODAY, AND IT IS THIS ONE'S COMPLEMENT. There the metric
could not SEE a defect; here it saw an improvement and scored it as a loss.
#772 stops hyphenating ragged and centred text (tex.web §852: a line carrying
infinite stretch has badness 0, so TeX's first pass succeeds and the hyphenating
pass is never reached). Its corpus A/B:
The affiliation block WITH NO SPACES BETWEEN THE WORDS — a centred line that was
overfull and had its interword glue shrunk to nothing to make it fit. Head sets Center for Theoretical, Electronic Engineering, Qilu Normal University, Jinan 250200. It also turns eight spurious hyphenations into whole words
(char-/acterized, follow-/ing, in-/dicated, repre-/sent, respec-/tively, sys-/tems, transfor-/mations, con/trary), which
is what tectonic sets.
The net −1 word is token boundaries around a stray 0.5 fragment, not text that
stopped appearing.
Why the metric got it backwards
Word recall counts reference words found in our text. Words that were FUSED
(CenterforTheoretical) and words that were SPLIT across a hyphen
(char- + acterized) are both already misses, so repairing them moves the
score by almost nothing — while an unrelated token boundary shifting by one
dominates the difference. The metric is not merely insensitive here; its sign
is wrong.
That is the same structural cause this issue names. The score is a proxy for
the reference, and when the proxy and the reference disagree the reference wins
— but nothing in the routine makes that disagreement visible. On #772 it took
building a word-multiset diff to see it, and that tool lived in a scratch
directory, exactly as this issue says the real-font kerning check did.
What I am proposing on top of the two options above
A word-multiset diff between two of OUR PDFs, as a tool in the
repository: which words one has that the other lacks. It does not need the
reference, it answers "what did this change actually do to the page" in one
command, and it is what made the above legible in about a minute. It is
complementary to (1) and (2): those measure against the oracle, this one
explains a delta.
I will put it up as cmd/gotex-worddiff unless someone objects; it is thirty
lines around the extractor the harness already uses.
⛔⛔ CORRECTION TO MY COMMENT ABOVE — and it makes this issue's point against
me rather than for me.
I wrote that #772's page was visibly better because base set an affiliation
block as CenterforTheoretical, ElectronicEngineering, QiluNormalUniversity
with no spaces between the words. That is an EXTRACTION ARTEFACT. The scratch
word-diff I ran read the PDFs with pdfops text; the harness reads them with
poppler's pdftotext, and through pdftotext those words do not differ at all.
The engine's own line dump shows the spaces present in BOTH files:
base y=120.19 x0=72.56 x1=561.63 | …; Center for Theoretical Physics of Complex …
head y=120.19 x0=72.56 x1=561.63 | …; Center for Theoretical Physics of Complex …
So the strongest piece of evidence I offered for "the page improved while the
score fell" was the second extractor disagreeing with the first.
What survives: the hyphenation differences are real and both extractors agree
on them (char-+acterized → characterized, and seven more), and they
follow what tectonic sets. The −0.1/−0.2 of word recall is NOT explained, and I
withdraw the claim that it was outweighed by a defect the change removed.
⚠ THE PROPOSAL IN MY COMMENT STANDS, AND THIS IS WHY. A word-multiset diff
belongs in the repository precisely because a scratch one reached for whatever
extractor was at hand. The version I am putting up (cmd/gotex-worddiff) reads
both files through a new internal/pdftext that gotex-refdiff is rewired onto,
so the diff and the score cannot disagree about what a word is. It found this
mistake within a minute of existing, by giving a different answer from the
scratch probe it replaced.
That is the same shape as the kerning defect this issue opened on: a number
that cannot see the page, and a probe that lives outside the repository until
it is needed.
⭐ A THIRD THING THE METRIC CANNOT SEE, AND THIS ONE IT ACTIVELY MIS-REPORTS:
THE EXTRACTOR FUSES COLUMNS, AND WHERE IT FUSES MOVES WHEN THE LINES DO.
gotex-refdiff scores with poppler's pdftotext and no -layout. On a
two-column paper that reads the page as ONE stream, gluing the end of one
column's line onto the start of another's. Real tokens from 2607.14549:
These are not in the PDF. They are the extractor's, and which boundaries
fuse depends on where the lines break — so any line-breaking change moves them,
and they reach the score as words that appeared or vanished.
Word-level difference between the same two builds:
extraction
words differing
plain
36 / 37
-layout
23 / 18
Every fused token is gone under -layout; what remains is the change's real
work (seven hyphenations repaired).
And the score itself, re-run with -layout extraction:
paper
plain
-layout
2607.14914
−0.2
1327 vs 1327 — no difference at all
2607.14549
−0.1
1020 vs 1019 — one word
One of the two apparent regressions was entirely the extractor.
Why this is NOT simply "turn on -layout"
-layout moves the ABSOLUTE scores by nine points on both sides (96.5% →
87.6%): the padding it inserts changes tokenisation everywhere, including the
reference's. Every historical number would move, and the mean would drop
without anything in the engine changing. That is its own trap — the one this
issue is about, from the other end.
So the honest statement is: for a two-column paper, the plain word-recall
delta has a noise floor set by column fusion, and that floor is larger than the
effects we are currently chasing. A −0.2 on a revtex paper is not evidence of
anything on its own.
Where that leaves the options
Alongside (1) box metrics and (2) a layout pass, and the (3) I proposed above:
Decide what the word score does about columns, deliberately, once. Either
it keeps fusing and we stop reading deltas below the fusion floor, or it
moves to a column-aware extraction and every stored number is re-baselined in
one pass with that stated. Doing neither means the number keeps moving for
reasons that are not the engine's.
I have not done (4) — it re-baselines the whole tracker and is not a side
effect of a line-breaking PR. cmd/gotex-worddiff -layout (#773) is what made
it measurable.
The blindness has a mechanism and an address, and it is on our side of the
boundary.
Where our kerning comes from
font.go:332-337:
// kernSP returns the inter-character kern in scaled points. It uses KernUnits (the// ...returnptToSP(o.fc.KernUnits(prev, cur) *o.fc.Scale())
KernUnits is the pair API. Read at go-opentype/opentype v0.21.1
(gpos.go:1640-1659), kernCovered walks the lookups the kern feature selects,
takes the pair-adjustment subtables and continues past every other kind:
pp, ok:=st.(pairPos)
if!ok {
continue
}
GPOS lookup type 7 (Contextual) and type 8 (Chained Contextual) position pairs
too. They are parsed there and the shaping path applies them — contextPos1/2/3 each carry apply(ctx *posContext, i int). So for a font that
kerns contextually, KernUnits returns 0 and ShapePositioned does not.
⛔ And 0 is what the API also returns for a pair the font deliberately leaves
alone. We could not tell "no kern here" from "I cannot evaluate this font", which
is the shape of blindness this issue describes.
⚠ Not fixable by asking the pair API harder
A contextual rule is matched against the glyphs around a position — backtrack,
input and lookahead coverage — which is why contextPos* take a context and an
index and expose no kern(left, right) at all. Holding only (prev, cur) we
cannot supply it. The question has no answer for such a font.
What has landed upstream
go-opentype/opentype#76 (open) adds Face.KerningIsContextual(), a per-face
answer to "can a pair query speak for this font's kerning at all". It is false for
the ordinary font and true when any kern lookup is contextual.
That contextual kerning accounts for the 1.12pt per "AV" this issue measured. I
have not found a font in our corpus that kerns contextually, and I have not looked
— that is step 2. What is established is the mechanism: if such a font is in
the corpus, this path cannot see its kerns, and nothing would have said so.
go-opentype/opentype#71 item (2) named this as a candidate and left open which API
we used. It is KernUnits.
Activity
tannevaled commentedon Nov 7, 2026
Correcting the framing of my own report, because it was too broad.
I wrote that "the fidelity metric cannot see a kerning defect". That is accurate for
scoreandlabeldiff, which compare page counts, and it is not accurate for the harness as a whole.hashdiffalready hashes the rendered page and reports the ink delta per document, and it ends its own output with:So the tool for this class of defect exists, knows what it is for, and says so. What is missing is narrower and more fixable than what I filed: the routine sweep does not run it, so the number anyone quotes — Σ, bias, exact — still comes from the page metric alone.
That changes the proposal. Running
hashdiffbesidelabeldiffin the routine path would have shown the kerning change on the two libertinus papers immediately, with no new code at all. The per-font box-metric test (proposal 1) is still worth having, because it localises a metric defect to a font and a pair instead of reporting that a page hash moved — but it is a second line of defence, not the first one.Demonstrated on #703 in the meantime: with the package reachable, 19 of 20 papers render differently and 9 of them keep the same page count, so nine real changes would have been reported as "aucun document n'a bougé" by the metric we steer by.
tannevaled commentedon Nov 13, 2026
⭐ A SECOND INSTANCE TODAY, AND IT IS THIS ONE'S COMPLEMENT. There the metric
could not SEE a defect; here it saw an improvement and scored it as a loss.
#772 stops hyphenating ragged and centred text (tex.web §852: a line carrying
infinite stretch has badness 0, so TeX's first pass succeeds and the hyphenating
pass is never reached). Its corpus A/B:
Two papers, both DOWN, nothing else moved. On the numbers alone that is a
regression and the change should not land.
What the page actually did
A word-multiset diff of the two PDFs for 2607.14549. Words base has and head
does not:
The affiliation block WITH NO SPACES BETWEEN THE WORDS — a centred line that was
overfull and had its interword glue shrunk to nothing to make it fit. Head sets
Center for Theoretical,Electronic Engineering,Qilu Normal University,Jinan 250200. It also turns eight spurious hyphenations into whole words(
char-/acterized,follow-/ing,in-/dicated,repre-/sent,respec-/tively,sys-/tems,transfor-/mations,con/trary), whichis what tectonic sets.
The net −1 word is token boundaries around a stray
0.5fragment, not text thatstopped appearing.
Why the metric got it backwards
Word recall counts reference words found in our text. Words that were FUSED
(
CenterforTheoretical) and words that were SPLIT across a hyphen(
char-+acterized) are both already misses, so repairing them moves thescore by almost nothing — while an unrelated token boundary shifting by one
dominates the difference. The metric is not merely insensitive here; its sign
is wrong.
That is the same structural cause this issue names. The score is a proxy for
the reference, and when the proxy and the reference disagree the reference wins
— but nothing in the routine makes that disagreement visible. On #772 it took
building a word-multiset diff to see it, and that tool lived in a scratch
directory, exactly as this issue says the real-font kerning check did.
What I am proposing on top of the two options above
repository: which words one has that the other lacks. It does not need the
reference, it answers "what did this change actually do to the page" in one
command, and it is what made the above legible in about a minute. It is
complementary to (1) and (2): those measure against the oracle, this one
explains a delta.
I will put it up as
cmd/gotex-worddiffunless someone objects; it is thirtylines around the extractor the harness already uses.
tannevaled commentedon Nov 13, 2026
⛔⛔ CORRECTION TO MY COMMENT ABOVE — and it makes this issue's point against
me rather than for me.
I wrote that #772's page was visibly better because base set an affiliation
block as
CenterforTheoretical,ElectronicEngineering,QiluNormalUniversitywith no spaces between the words. That is an EXTRACTION ARTEFACT. The scratch
word-diff I ran read the PDFs with
pdfops text; the harness reads them withpoppler's
pdftotext, and throughpdftotextthose words do not differ at all.The engine's own line dump shows the spaces present in BOTH files:
So the strongest piece of evidence I offered for "the page improved while the
score fell" was the second extractor disagreeing with the first.
What survives: the hyphenation differences are real and both extractors agree
on them (
char-+acterized→characterized, and seven more), and theyfollow what tectonic sets. The −0.1/−0.2 of word recall is NOT explained, and I
withdraw the claim that it was outweighed by a defect the change removed.
⚠ THE PROPOSAL IN MY COMMENT STANDS, AND THIS IS WHY. A word-multiset diff
belongs in the repository precisely because a scratch one reached for whatever
extractor was at hand. The version I am putting up (
cmd/gotex-worddiff) readsboth files through a new
internal/pdftextthat gotex-refdiff is rewired onto,so the diff and the score cannot disagree about what a word is. It found this
mistake within a minute of existing, by giving a different answer from the
scratch probe it replaced.
That is the same shape as the kerning defect this issue opened on: a number
that cannot see the page, and a probe that lives outside the repository until
it is needed.
gotex-worddiff -layout, and the column fusion it found under #772's r…
tannevaled commentedon Nov 13, 2026
⭐ A THIRD THING THE METRIC CANNOT SEE, AND THIS ONE IT ACTIVELY MIS-REPORTS:
THE EXTRACTOR FUSES COLUMNS, AND WHERE IT FUSES MOVES WHEN THE LINES DO.
gotex-refdiffscores with poppler'spdftotextand no-layout. On atwo-column paper that reads the page as ONE stream, gluing the end of one
column's line onto the start of another's. Real tokens from 2607.14549:
These are not in the PDF. They are the extractor's, and which boundaries
fuse depends on where the lines break — so any line-breaking change moves them,
and they reach the score as words that appeared or vanished.
Measured, on #772's two papers
Word-level difference between the same two builds:
-layoutEvery fused token is gone under
-layout; what remains is the change's realwork (seven hyphenations repaired).
And the score itself, re-run with
-layoutextraction:-layoutOne of the two apparent regressions was entirely the extractor.
Why this is NOT simply "turn on -layout"
-layoutmoves the ABSOLUTE scores by nine points on both sides (96.5% →87.6%): the padding it inserts changes tokenisation everywhere, including the
reference's. Every historical number would move, and the mean would drop
without anything in the engine changing. That is its own trap — the one this
issue is about, from the other end.
So the honest statement is: for a two-column paper, the plain word-recall
delta has a noise floor set by column fusion, and that floor is larger than the
effects we are currently chasing. A −0.2 on a revtex paper is not evidence of
anything on its own.
Where that leaves the options
Alongside (1) box metrics and (2) a layout pass, and the (3) I proposed above:
it keeps fusing and we stop reading deltas below the fusion floor, or it
moves to a column-aware extraction and every stored number is re-baselined in
one pass with that stated. Doing neither means the number keeps moving for
reasons that are not the engine's.
I have not done (4) — it re-baselines the whole tracker and is not a side
effect of a line-breaking PR.
cmd/gotex-worddiff -layout(#773) is what madeit measurable.
gotex-worddiff: which words moved, read through the extractor the sco…
every accented word broke at an offset, and the suite was green throu…
tannevaled commentedon Nov 16, 2026
The blindness has a mechanism and an address, and it is on our side of the
boundary.
Where our kerning comes from
font.go:332-337:KernUnitsis the pair API. Read atgo-opentype/opentypev0.21.1(
gpos.go:1640-1659),kernCoveredwalks the lookups thekernfeature selects,takes the pair-adjustment subtables and
continues past every other kind:GPOS lookup type 7 (Contextual) and type 8 (Chained Contextual) position pairs
too. They are parsed there and the shaping path applies them —
contextPos1/2/3each carryapply(ctx *posContext, i int). So for a font thatkerns contextually,
KernUnitsreturns 0 andShapePositioneddoes not.⛔ And 0 is what the API also returns for a pair the font deliberately leaves
alone. We could not tell "no kern here" from "I cannot evaluate this font", which
is the shape of blindness this issue describes.
⚠ Not fixable by asking the pair API harder
A contextual rule is matched against the glyphs around a position — backtrack,
input and lookahead coverage — which is why
contextPos*take a context and anindex and expose no
kern(left, right)at all. Holding only(prev, cur)wecannot supply it. The question has no answer for such a font.
What has landed upstream
go-opentype/opentype#76 (open) adds
Face.KerningIsContextual(), a per-faceanswer to "can a pair query speak for this font's kerning at all". It is false for
the ordinary font and true when any kern lookup is contextual.
That gives this issue two next steps, in order:
figure we cannot read must not arrive as a zero — the same rule the load gate
now enforces for corpus measurements (Instruments carry their own conditions: a shared load gate, a shared PDF extractor, and the A/B reports ink beside pages #805).
If none has one, this is a correctness hole with no corpus cost and it is
recorded as such; if some do, we have the size of it and the case for driving
the shaping path (
ShapePositionedUnits, which a shaped run gets an unrounded form, or no typesetter can use the shared one go-opentype/opentype#65 wasmerged to provide "or no typesetter can use the shared one" — Architecture roadmap: the page model, the per-line measure, and the shaper we already depend on but never call #792's "the
shaper we already depend on but never call").
⚠ Not claimed
That contextual kerning accounts for the 1.12pt per "AV" this issue measured. I
have not found a font in our corpus that kerns contextually, and I have not looked
— that is step 2. What is established is the mechanism: if such a font is in
the corpus, this path cannot see its kerns, and nothing would have said so.
go-opentype/opentype#71 item (2) named this as a candidate and left open which API
we used. It is
KernUnits.Refs go-opentype/opentype#76, Refs go-opentype/opentype#71, Refs #792.
🤖 Generated with Claude Code
a pair query can say it cannot speak for this font's kerning, instead…
a kerning we cannot read is reported, not returned as zero (#716) (#807)
a heading starts at the margin: one space token moved every one of th…