Skip to content

A kerning we cannot read is reported, not returned as zero (#716) - #807

Merged
tannevaled merged 3 commits into
mainfrom
kerning-we-cannot-read
Nov 17, 2026
Merged

tannevaled merged 3 commits into
mainfrom
kerning-we-cannot-read

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

A kerning we cannot read is reported, not returned as zero

kernSP (font.go:336) asks go-opentype for the kern between two glyphs, and
that is a pair query. GPOS lookup types 7 (Contextual) and 8 (Chained
Contextual) position pairs too, and a pair query cannot evaluate them: such a rule
is matched against the glyphs around a position, which (prev, cur) does not
carry. The library's kernCovered skips those subtables and answers 0 — the
same 0 it answers for a pair the font deliberately leaves alone.

Nothing here distinguished the two, and that is #716: a kerning defect of
1.12pt per "AV" invisible to every number this engine's fidelity measurement
steers by.

go-opentype/opentype v0.22.0 (go-opentype/opentype#76) reports the condition
per face, and this surfaces it as Diagnostics.KerningIsAFloor, beside the other
silent-swallow flags, where a reader of a corpus run will see it.

What this is not

⚠ It is not the fix for the kerning itself. kernSP still returns the pair
answer. Driving the shaping path — which has the glyph sequence a contextual rule
needs — is #792's "the shaper we already depend on but never call" and is not
this change. What this change does is stop a floor from passing for a measurement.

⚠ It is not a claim that any kern was wrong. Censused the 81 font files
go-opentype/[email protected] bundles, with the new API:

fonts parsed 81
with a kern the pair API can see 48
kerning is contextual 8

Seven are complex-script Noto faces where contextual positioning is expected; the
eighth is notosans.ttf, a general Latin/Greek/Cyrillic sans. So the condition is
neither rare nor exotic. Whether it fires on a given document's text, and by how
much, this flag does not say.

⚠ And that population is not the corpus's. The papers measured here are set in
Latin Modern, Libertinus, STIX and TeX Gyre, none of which is in that collection.
Sizing the effect on the corpus needs those font files; it is #716's own next step
and is not done.

⛔ The hole my own tests would have hidden

noteKerningFloor is hooked into SetFont and selectFont.

SetFont is how a host installs the base face once. \rmfamily, \ttfamily, a
math font and every size change come through selectFont — so a flag hooked only
into SetFont would be blind to every switch a document makes, and the first
two tests would still have passed in full
, because they switch faces the way a
host does and not the way a document does.

That was found by reading selectFont after writing them, not by running them. A
third test goes in through selectFont, inside a group, and asserts the flag
survives the group's end: selectFont restores the previous face, and the text
set in that group still carries kerns we could not read.

Witnesses

Four rows, boundary covered on both sides:

a face whose kerning is a floor must raise it
a pair-adjustment face must not — otherwise the flag says nothing at all
a face that cannot be asked must not either, and this row explains the design
through selectFont, inside a group raises it, and the group's end does not clear it

⛔ noteKerningFloor is a type assertion and not a fontFace method, on
purpose. fontFace is implemented by this package's mocks, which have no font
behind them, and widening the interface would force every one of them to answer a
question about OpenType lookups that has no meaning for a mock. The assertion
failing is the right answer, not a missing case — and the third row is what says
so.

⚠ The witnesses test the wiring, not a font. A test asserting "notosans.ttf
kerns contextually" would be an assertion about a third-party font's internals
that a version bump may flip for reasons unrelated to this engine. The evidence
that real fonts do this is the census above, recorded on
go-opentype/opentype#71; the detection itself is covered by that library's own
tests.

Measured

go test -count=1 ./... — 11 packages, 0 failures, uncached, at a 1-minute load
of 6.28 (under the threshold cmd/internal/loadguard enforces for
measurements).

go.mod goes to go-opentype/opentype v0.22.0. ⛔ modtidy refused the first
push because go get had left go.sum carrying both versions; tidied and
re-tested before pushing.

Refs #716 — this gives its blindness a mechanism and a flag; it does not close it,
because the kern is still the pair answer.
Refs #792 — the shaping path stays its business.
Refs go-opentype/opentype#71, Refs go-opentype/opentype#76.

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 16, 2026 22:46
kernSP asks go-opentype for the kern between two glyphs, and that is a PAIR
query. GPOS lookup types 7 (Contextual) and 8 (Chained Contextual) position pairs
too, and a pair query cannot evaluate them: such a rule is matched against the
glyphs AROUND a position, which (prev, cur) does not carry. go-opentype's
kernCovered skips those subtables and answers 0 -- the same 0 it answers for a
pair the font deliberately leaves alone.

Nothing here distinguished the two, and that is #716: a kerning defect of 1.12pt
per "AV" invisible to every number this engine's fidelity measurement steers by.

go-opentype/opentype v0.22.0 (go-opentype/opentype#76) reports the condition per
face, and this surfaces it as Diagnostics.KerningIsAFloor, beside the other
silent-swallow flags, where a reader of a corpus run will see it.

⚠ IT IS NOT THE FIX FOR THE KERNING ITSELF. kernSP still returns the pair answer.
Driving the shaping path, which has the glyph sequence a contextual rule needs, is
#792's "the shaper we already depend on but never call" and is not this change.
What this change does is stop a floor from passing for a measurement.

⚠ AND IT IS NOT A CLAIM THAT ANY KERN WAS WRONG. Measured over the 81 fonts
go-opentype/fonts bundles, 8 carry such lookups -- seven complex-script Noto
faces and notosans.ttf, a general Latin sans -- so the condition is neither rare
nor exotic. Whether it fires on a given document's text, and by how much, this
flag does not say. Sizing that needs the corpus's own fonts (Latin Modern,
Libertinus, STIX, TeX Gyre), which are not in that population.

## The hole my own tests would have hidden

noteKerningFloor is hooked into SetFont AND selectFont. SetFont is how a HOST
installs the base face once; \rmfamily, \ttfamily, a math font and every size
change come through selectFont, so a flag hooked only into SetFont would be blind
to every switch a DOCUMENT makes -- and the first two tests would still have
passed in full, because they switch faces the way a host does.

That was found by reading selectFont after writing them, not by running them. A
third test goes in through selectFont, inside a group, and asserts the flag
survives the group's end: selectFont restores the previous face, and the text set
in the group still carries kerns we could not read.

## Witnesses

Four rows, with the boundary covered on both sides: a face whose kerning is a
floor must raise it, a pair-adjustment face must NOT (or the flag says nothing at
all), and -- the row that explains the design -- a face that cannot be ASKED must
not raise it either.

⛔ noteKerningFloor is a type assertion and not a fontFace method on purpose.
fontFace is implemented by this package's mocks, which have no font behind them,
and widening the interface would force every one of them to answer a question
about OpenType lookups that has no meaning for a mock. The assertion failing is
the right answer, not a missing case, and that row is what says so.

⚠ The witnesses test the WIRING, not a font. A test asserting "notosans.ttf kerns
contextually" would be an assertion about a third-party font's internals that a
version bump may flip for reasons unrelated to this engine. The evidence that real
fonts do this is the census on go-opentype/opentype#71; the detection itself is
covered by that library's own tests.

Verified uncached: go test -count=1 ./... -- 11 packages, 0 failures, at a
1-minute load of 6.28.

Refs #716, Refs #792, Refs go-opentype/opentype#71.

Co-Authored-By: Claude Opus 5 <[email protected]>
tannevaled added a commit that referenced this pull request Nov 17, 2026
…tor, because -race costs 6.65x (#811)

MEASURED (#799). Quiet machine, GOMAXPROCS=1 -parallel 1 -count=1, arms
INTERLEAVED and the order REVERSED so a drift during the pass shows up as a
disagreement between orders instead of reading as an effect:

	                run 1        run 2
	plain           17.486 s     18.175 s
	-race          116.361 s    121.046 s

	A1 -> B1  6.65x        B2 -> A2  6.66x     (agree to 0.2%)

windows-latest was failing at 1800.5 s against its own 1800 s bound, one push run
in four. That left `main` ITSELF red a quarter of the time, so "is main green?"
had no stable answer, ghrelease could not tag on its first try, and three open
pull requests (#807, #809, #810) were red on this lane and on nothing else --
#810 changes only a comment.

At 6.65x the lane was not 10% away from comfortable, it was most of an order of
magnitude away. #156 and #653 already raised this bound twice; a third raise buys
a few months and the same recurrence. Expected after this change: ~270 s.

⚠ AND THAT ESTIMATE IS PESSIMISTIC: the race detector's overhead on Windows is
commonly HIGHER than on darwin, and a higher multiplier means a bigger saving.

## What is given up, named

A data race reachable ONLY through Windows-specific code. A race is a property of
the Go program and Go's memory model is platform-independent, so everything else
is still caught on ubuntu and macos, on every push and every pull request.

The conformance ratchet and the 80% coverage floor still run on windows:
platform BEHAVIOUR is still covered there. Only the detector is dropped.

## Why the matrix and not a shell branch

The policy is declared in the matrix -- `{ os: windows-latest, race: '' }` --
rather than branched on inside the step, so that reading the matrix tells you
which lane guarantees what. A reader looking for "where does -race run" finds the
answer in one place.

## ⚠ What is NOT changed, deliberately

The 30m bound stays, although ~270 s is expected. The first green run on this
lane is what measures the new time, and changing two things at once would leave
nobody able to say which did it. Once that number exists the bound can come down
to something that would catch a real deadlock quickly.

Verified: wfaudit reads the workflow (1 read, 0 unreadable, no findings), and
`go test -count=1 ./...` is green on 11 packages at a 1-minute load of 3.16.

Closes #799.

Co-authored-by: Claude Opus 5 <[email protected]>
@tannevaled
tannevaled merged commit efd3e3a into main Nov 17, 2026
18 checks passed
@tannevaled
tannevaled deleted the kerning-we-cannot-read branch November 17, 2026 12:44
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