Rune · rendering research · 27 October 2026

Inside macOS
font smoothing

Measured on macOS 15.3

CoreGraphics’ glyph dilation, curve flattening and small-size autohinter, reconstructed in Rust. The outlines match to floating-point precision. The complete renderer comes within 3 alpha levels of native macOS.

Follow-up to Rune vs macOS, pixel by pixel. This time we modelled the smoothing precisely and checked an independent implementation against native CoreText/CoreGraphics output.

14,400public CoreGraphics mask comparisons
3 / 255worst alpha error, including small sizes
0%pixels off by more than 8 levels
1,800native dilated outlines reconstructed

The measured result

Inter Regular, 32 device pixels, ink #1d1e22, fractional origin (¼, 1/64). Switch between the actual masks. These illustrations are enlarged 3× without interpolation.

Measured I H T em dash slash A V S o g at sign and 8 glyph masks Swash design-unit outlines → recovered pipeline → zeno coverage. No CoreGraphics calls in this Rust render.
The outline problem is solved on the test corpus. All 1,800 reconstructed paths have the same commands as Apple’s; the largest coordinate discrepancy is 1.71 × 10⁻¹² px. They rasterize identically through zeno. The remaining native-mask difference is in coverage arithmetic.

A five-bucket formula

The input is the text colour’s linear-sRGB luminance. CoreGraphics rounds it to the nearest quarter, then chooses a size-proportional radius with a fixed cap.

// Convert foreground RGB to linear sRGB first
Y = 0.2126 R + 0.7152 G + 0.0722 B
q = round(4 Y) / 4
d = min(ppem × (0.0058 + 0.01 q), 0.3f)

d is a radius: left and right grow by d; the top grows by 2d. The cap is the exact f32 literal 0.30000001192092896, promoted to double. There is no large-size cutoff.

Explore the recovered formula
Linear luminance0.0130Bucket q0.00Radius / px0.1856

Each line is one luminance bucket. All converge at a 0.3 px radius. The marker follows the controls.

Linear Yqd at 32 px
0 to .1250.1856
.125 to .375.25.2656
.375 to .625.50.3000
.625 to .875.75.3000
.875 to 11.3000

Lower boundary inclusive; upper exclusive except at 1. Encoded grey boundaries are ≈ .389, .646, .812 and .943.

A 4,097-grey internal-function sweep matched the formula at every sample. A separate glyph-mask sweep confirmed the five visible steps at 16 px.

Correction to the earlier report: its .1875/.375 px estimate is close, but the exact dark-ink values at 32 px are .1856/.3712. Alpha quantization hid the difference.

Move whole pieces, then connect them

+2d upward −d+d bottom edge stays at baselineoriginal bevel connector

Expansion exaggerated for clarity. A rectangle becomes an eight-sided outline, not a larger square-cornered rectangle.

  1. Orient the whole glyph. Reverse all contours together if necessary; preserve the opposite winding of holes.
  2. Split curves at extrema. Convert quadratics to cubics; split into x/y-monotonic pieces.
  3. Translate each piece. Its displacement comes from direction signs, not a normalized surface normal.
  4. Join the pieces with straight lines. This creates the characteristic bevels and grows counters inward.
// y-up coordinates; P → Q is one piece
sx = sign(Q.y - P.y) × d
sy = -sign(Q.x - P.x) × d + d

translate all its points by (sx, sy)

Zero has sign zero. A diagonal receives the full x and y offsets. A monotonic curve keeps its shape and moves as a unit.

Order is observable. Apply the fractional origin before dilation. Apple mixes f32 state with f64 computations; changing the order changes some near-zero direction decisions. On this corpus, the right order eliminated isolated 63-level errors.

The integer-baseline mystery, explained

At small sizes the old study found puzzling changes when a baseline landed exactly on an integer. The answer: a small-size autohinter that warps glyphs vertically.

At eligible integer sizes 7–18 px, with zero vertical phase, CoreGraphics reshapes the outline vertically. It uses the bounding-box tops of the glyphs “o” and “X” to choose snapped target heights, then applies a piecewise y transform to every outline point after dilation.

T at 16 pixels with dilation but no metric autohint
Dilation + flattening only
Native CoreGraphics T at an integer baseline
CoreGraphics
Rust T with the recovered metric autohinter
+ recovered autohinter

Inter Regular T, 16 px, integer baseline, shown at 12×. All three use the same font and requested position.

Recovered and checked

The Rust transform matches 180 directly captured native transforms, with maximum parameter error 1.89 × 10⁻¹⁵. No validity decisions disagree.

Target selection uses a historical reference radius min(ppem × .015125, .3); the final transform uses the actual colour-dependent radius.

Also recover the flattening

CoreGraphics recursively halves curves using squared second differences. Its thresholds are .64 for quadratics and .07111111111111111 for cubics.

Flatten to lines with those rules before feeding zeno. This removes most of what previously looked like an irreducible curve-rasterizer difference.

How close is it?

Three fonts; 12 glyphs covering stems, bars, diagonals, curves and counters; ten sizes from 8–72 device px; five colours; four phases; 1× and 2× backing. Error is measured over each glyph’s tight union ink bounds plus one pixel of padding.

Pipeline vs native smoothed CGMean /255Max /255Pixels >1Pixels >8
Unhinted outline → ordinary zeno12.7993422522.3954%19.7794%
+ recovered dilation.853151555.1096%2.8010%
+ CoreGraphics flattening.258921551.6488%.4665%
+ phase before dilation.242801551.4489%.3975%
+ recovered autohinter.112933.7458%0%
Independent Swash outlines & metrics¹.109493.7079%0%

First five rows: 14,400 cases / 7,115,310 cropped pixels, using unhinted CoreText outlines to isolate each stage. ¹9,600 Inter Regular/Bold cases / 4,910,896 pixels, with the entire tested Rust path using Swash extraction and its own font metrics. Reference masks always come from public CTFontDrawGlyphs.

Not byte-exact yet. Apple uses 12-bit vertex coordinates and its own fixed-point slope and coverage arithmetic. Zeno’s line rasterizer differs slightly. An independent analytic-area experiment reduced the >1 share to .0933%, but its maximum is still 3. The remaining work is scan conversion, not a missing smoothing-strength heuristic.

What this does and does not establish

The ≤3 bound is measured for this corpus on macOS 15.3. It covers integer baselines as well as fractional positions. It does not establish universal identity for arbitrary cubics, rotations/shears, variable or colour fonts, HDR colours, other font-provider eligibility rules, or later macOS versions. Main-corpus subpixel quantization is disabled to isolate the requested phases. The earlier ¼-point flooring observation remains a separate upstream positioning concern.

A practical path for Rune / Swash

Swash @ design units→f64 scale + phase→dilation→y autohint→CG flattening→zeno lines

Extract at unitsPerEm, then scale in f64. Swash’s final-size outline extraction has already rounded coordinates. Feeding those points into the correct algorithm left outliers up to 65 levels; using design-unit outlines reduced the maximum to 3.

let outline = scaler_at_units_per_em.scale_outline(glyph_id)?;
let path = scale_path(&from_zeno(outline.path().commands()), ppem / upem);
let prepared = prepare_outline(&path, ppem, srgb_ink, phase, metrics);
// prepared is a polyline; rasterize it with zeno.

Cache by luminance bucket as well as font, size and phase. Composite ordinary coverage in the context’s encoded colour space to match the tested CG context. Drop the earlier compensating coverage-gamma adjustment when using this model.

Two more corrections from the experiments

Alpha-only does not mean white. An alpha-only context with explicitly black ink produced exactly the black RGBA mask; white ink produced the white mask. The previous harness happened to set white. The private setters do not override modern text weight. Dilation 0/1, several smoothing styles and contrast 0/10 all left the tested draw unchanged, because the drawing delegate temporarily replaces the settings with its colour-dependent custom style.

Prior art

Prior art helped find the right trail: Pathfinder’s historical constants, WebRender’s colour-aware masks, Skia’s mac scaler, and Zed’s 2026 luminance-bucket investigation. The current grayscale algorithm takes a different branch from the older Pathfinder factors.

Algorithm specification ↗Aggregate results JSON ↓Additional checks ↓Complete test corpus · 6.6 MB ↓Per-case errors ↓