Engineering Journal
Pdf Processor
Pdf Processor

The glyph that starved every rule: size gates and the square root

2026-08-20

TLDR

A single square root in a paragraph silently flattened every fraction in the same document. The radical glyph is tall by design, it inflated the shared body-size threshold, and suddenly no glyph pair qualified as a fraction anymore. The fix was to compute the size gate over the population the rule applies to, excluding stretch delimiters. Thresholds computed from a heterogeneous population leak the outlier into every downstream decision.

Bug class: one outlier inflating a shared gate

Geometry-based document extraction gates every structural rule on a size estimate. Is this glyph full size or a script? Is this row a fraction row or a baseline? One body-size number answers all of it.

The number was computed as the median of every glyph size in the expression. Innocent, until the expression contained a square root. The radical is tall because its job is to span the radicand. It is structural height, not typographic height, but the median did not know that. The estimate rose, the threshold rose, and every fraction row in the same document fell below it. 1/2 came out as flat text 1/2, because the pairing rule no longer believed two rows could be a fraction.

Why the API produces it

There is no API here, only geometry. The defect is conceptual. A shared gate is a population statistic, and the population feeding it included glyphs that exist to be taller than their neighbors. Any rule that consumes a gate has no way to know the gate was corrupted, so the corruption propagates silently to every rule downstream.

The failure was deterministic and quiet. One radical anywhere in the paragraph, and the whole paragraph lost its fractions. Nothing threw, nothing logged. The output was simply worse.

The fix with explanation

Split the population before measuring. Compute the body-size estimate from the glyphs the rule will actually classify: ordinary letters, digits, operators. Exclude stretch delimiters, radicals and tall brackets, the glyphs whose height is structural.

// Before: the radical inflated the shared threshold
const bodySize = median(atoms.map(a => a.size));

// After: structural glyphs do not set the typographic baseline const bodySize = median( atoms.filter(a => !isStretchDelimiter(a)).map(a => a.size) );

With the radical out of the population, the threshold returned to the size of ordinary text, and fraction pairing resumed across the whole document. The same discipline applies to the gap gates: a superscript's overhang is measured against the farthest absorbed right edge, not against the previous atom, so a hanging script cannot weld two columns together.

How to prevent the class

Audit every shared gate for population leakage. Ask who feeds the statistic and who consumes it, and make the two populations match. If a glyph's measurement exists to be exceptional, it does not belong in the statistic that defines what ordinary looks like. Pin the case in the test suite: a document containing a radical must still produce the exact same fraction output as the same document without it.

The one generalizable lesson

A threshold computed from a heterogeneous population does not define the average, it defines the outlier. Every rule that reads the threshold inherits the outlier's distortion, silently. Measure the population the rule governs, not the population that happens to be in the same paragraph.

Read this post in the full Engineering Journal →