Metal: mild coverage gamma to match NS glyph weight (F3)

The NS (CoreGraphics) backend renders on-screen text slightly heavier
(more ink at every coverage level) due to its coverage gamma / stem
darkening, leaving plain linear-coverage Metal text a touch lighter.
Apply coverage = pow(coverage, 0.82) in the glyph fragment shader to lift
coverage uniformly and match NS's weight.

Dense-text ink ratios vs NS moved from 0.88-0.92 to 0.96-0.99, mean gray
247.6 -> 247.25 (NS 246.95), and AE improved 3.40% -> 3.32%; the "Hola
Mundo" baseline AE stays at 0.88% and is visually identical (no
over-bolding).
This commit is contained in:
Andros Fenollosa 2026-06-03 08:30:53 +02:00
parent c1f9d62b27
commit 195342091f

View file

@ -118,6 +118,11 @@ fragment float4 glyph_fragment(GlyphOut in [[stage_in]],
texture2d<float> atlas [[texture(0)]],
sampler smp [[sampler(0)]]) {
float coverage = atlas.sample(smp, in.texCoord).r;
// F3: the NS (CoreGraphics) backend renders on-screen text slightly heavier
// (more ink at every level) thanks to its coverage gamma / stem darkening.
// Plain linear coverage leaves Metal text a touch lighter than NS. Apply a
// mild gamma (<1) to lift coverage uniformly and match NS's weight.
coverage = pow(coverage, 0.82);
return float4(in.color.rgb, in.color.a * coverage);
}