auto_kern
Automatically kern glyph pairs using optical gap analysis. Measures white-space between letters and calibrates to reference values for balanced spacing.
Instructions
Auto-kern glyph pairs using optical gap analysis (MB LetterKerner algorithm).
Measures the optical white area between each glyph pair using horizontal ray-casting, weighted by a trapezoidal function (full weight at baseline–xHeight, tapered in descender/ascender zones), then solves for the kern value that makes each pair's gap area match a calibration reference.
Auto-calibrates from nn (lowercase) and HH (uppercase) if no area is given.
Recommended workflow:
Finalize spacing first (kerning can't fix bad spacing)
Assign kerning groups: analyze_kerning_groups(apply=True)
Preview: auto_kern(pairs="critical", dry_run=True)
Apply critical: auto_kern(pairs="critical")
Expand: auto_kern(pairs="auto") — all group combinations
Verify: analyze_kerning()
Args: pairs: Pair selection mode: "critical" — ~75 essential pairs (AV, AT, To, Va, etc.) "auto" — generate representative pairs per kerning group combination "explicit" — use pairs_list pairs_list: Explicit pairs when pairs="explicit", e.g. [["A","V"],["T","o"]] area: Target gap area in units². None = auto-calibrate from nn/HH. step: Vertical sampling interval (default 5u, smaller = more precise) depth: Max probe depth per side (default 200u) factor: Optical correction factor (default 1.25, matches HT LetterSpacer) rounding: Round kern values to multiples of this (default 5) threshold: Skip kern values with abs < threshold (default 3) use_groups: Use group kerning keys (default True, strongly recommended) overwrite: Overwrite existing kerning (default False) dry_run: Preview only, don't apply (default False) master_id: Process only this master (empty = all masters)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| area | No | ||
| step | No | ||
| depth | No | ||
| pairs | No | critical | |
| factor | No | ||
| dry_run | No | ||
| rounding | No | ||
| master_id | No | ||
| overwrite | No | ||
| threshold | No | ||
| pairs_list | No | ||
| use_groups | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |