From d45844a17f649a082e445ee700c21d9b3e032e56 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Wed, 3 Jun 2026 08:30:53 +0200 Subject: [PATCH] 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). --- src/mtlterm.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mtlterm.m b/src/mtlterm.m index 1f4e5c9d178..6e90018ed10 100644 --- a/src/mtlterm.m +++ b/src/mtlterm.m @@ -118,6 +118,11 @@ fragment float4 glyph_fragment(GlyphOut in [[stage_in]], texture2d 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); }