Metric
The type designer's spacing remains authoritative. This should stay the default and is usually the right choice for a well-made font used as intended.
Independent research workbench
This project tests whether a deterministic algorithm can improve display-text spacing when a font's built-in kerning is missing, sparse, or visually weak, without throwing away good font spacing.
Typst is an open-source, markup-based typesetting system for documents and presentations. It currently exposes kerning as an on/off text option; this workbench investigates a possible opt-in optical mode.
Current answer
The direction works well on the targeted Latin display-text corpus, and a smaller extracted kernel now runs inside a separate Typst compiler prototype. A broad font audit exposed a preservation failure, and the current prototype now includes a bounded response.
The research candidate's combined mean difference across 61 cases
is 0.0146em. The smaller compiler-facing candidate
scores 0.0222em mean across the current 30-case
no-ligature suite and 0.0156em across the 31-case
ligature suite after metric preservation. This is evidence for a
technical direction, not proof of universal typographic quality.
A 15-font audit initially found 659 cases where the
compact candidate changed the sign of effective font kerning. The
bounded-prior version changes none and limits its maximum movement
from existing positioning to 0.0300em.
Kerning changes the horizontal space between neighboring shaped glyphs. In metric kerning, the layout engine follows spacing and positioning data supplied by the font and shaping system. In optical kerning, the actual glyph shapes are also examined so visually uneven gaps can be corrected.
The type designer's spacing remains authoritative. This should stay the default and is usually the right choice for a well-made font used as intended.
A computed alternative for visible spacing problems, especially large titles, acronyms, display type, weak kern data, mixed shapes, and fonts used outside their intended size.
Large poster and presentation titles expose these problems quickly:
a gap such as W|A, A|V, o|T,
or 1|0 can look too open or too tight even when the
numeric advances are valid. Manual tracking fixes one line, but it
does not provide a reusable document-level behavior.
Context: Practical Typography's critical comparison of metric and optical spacing. This benchmark follows its central caution: optical is an option for a problem case, not a replacement for good font metrics.
InDesign Optical is the external publishing reference in this workbench because designers already know it and use it in production. The goal is not to reverse-engineer Adobe or declare its output to be ground truth. It gives reviewers a real, inspectable answer to “compared with what?”
Every optical comparison first passes a metric-parity gate: Typst and InDesign must use the same static font instance, text, size, ligature setting, and closely matching metric output. Only then is the InDesign Optical result compared with the Typst candidate.
OpenType remains a visible outlier.
Inspect the full method in the InDesign baseline specification and metric-parity gate. The separate academic display report contains both 80 pt and 100 pt results.
The result of this work is a guarded hybrid algorithm, not one spacing
constant. The benchmark first tested nearest-contour distance,
whitespace profiles, area balance, metric-prior blending, and
conservative fallback behavior. Their failures led to the full
guarded-profile-hybrid research reference and then to the
smaller compact-guarded runtime candidate.
em.
fi becomes one
glyph, the algorithm spaces that glyph against its neighbors; it
does not insert kerning inside the ligature.
Read the algorithm and candidate-selection notes, the runtime and compiler prototype results, or the technical evaluation.
The first table records the full research reference. The smaller compiler-facing candidate and its preservation trade-off follow directly below it.
| Research reference suite | Measured cases | Mean difference | Worst difference |
|---|---|---|---|
| No ligatures | 30 / 30 | 0.0170em |
0.0304em |
| Ligatures enabled | 31 / 31 | 0.0123em |
0.0240em |
| Combined | 61 / 61 | 0.0146em |
0.0304em |
These scores measure rendered position and width differences against InDesign Optical. They make regressions visible; they do not replace visual review or prove that InDesign is always preferable.
The extracted compact-guarded kernel was compared with
two deliberately simpler controls on the same 30 no-ligature cases:
nearest contour scored 0.2914em mean, fallback only
0.1061em, and the current bounded compact candidate
0.0222em.
On the 31-case ligature suite, bounded compact scores
0.0156em mean and 0.0360em worst. The separate
compiler prototype matches the workbench's expected width correction
in all 61 current cases within 0.000049em.
A second audit compared the candidate with effective kerning already
present in 15 Google Fonts. It retained 15,271 pairs and
initially found 659 sign changes and a
0.2720em maximum difference. The generic bounded-prior
rule reduces the mean difference from 0.0206em to
0.0095em, caps the maximum at 0.0300em, and
removes all sign changes. No font or glyph exceptions were added.
See the current findings and known residual differences and the machine-readable font metric agreement audit and the before/after preservation report.
There is an active upstream discussion in Typst issue #8514, but no assigned implementation or accepted API shape. The current repository is not a merge-ready patch. Its job is to make the algorithmic direction and its tradeoffs concrete.
1 · Complete
Reproducible fonts, shaping, algorithms, InDesign baselines, visual sheets, metrics, and regression cases.
2 · Complete
Extracted dependency-free runtime kernel, post-shaping Typst integration, font/glyph caches, parity checks, and compiler measurements.
3 · Current
Decide whether the behavior and complexity are worth pursuing, then agree on API, scope, and font-positioning semantics.
4 · Current
Review the bounded metric policy, expand scripts and font classes, lock compatibility tests, and only then propose a focused PR.
The exact API remains open. A deliberately small sketch is to preserve the current boolean behavior and add an optical mode rather than prematurely renaming every metric source:
#set text(kerning: true) // current behavior
#set text(kerning: false) // current disabled behavior
// Possible future direction, subject to upstream design:
#set text(kerning: "optical")
The technical milestones, open decisions, and useful community contributions are listed in Path to a Typst Prototype. Concrete implementation and timing evidence is in the runtime prototype report.
crates/optikern-coreFont loading, shaping, outline profiles, algorithm candidates, guards, and tests.
crates/optikern-runtimeDependency-free compact pair/run decision kernel used by the compiler experiment.
scripts/Typst and InDesign runs, parity gates, comparison suites, and reproducible figure generation.
corpus/ and baselines/Pinned font definitions, sample matrices, compact current evidence, and regression inputs.
docs/Algorithm rationale, rendering contracts, current findings, research sources, and the upstream path.