From d56f41f7894de8fb1032f059f71263f210f42899 Mon Sep 17 00:00:00 2001 From: Alexey Ushakov Date: Thu, 11 Jun 2020 17:27:01 +0300 Subject: [PATCH] JBR-1929 Improve rendering of San Francisco font of macOS Catalina Added gamma correction to match grayscale rendering with subpixel one (cherry picked from commit 5016db518a29570fa07f13deb2724df9efc75053) --- .../macosx/native/libawt_lwawt/font/CGGlyphImages.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m b/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m index ce3dc2c03036..85135df4685f 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m @@ -282,7 +282,13 @@ CGGI_CopyImageFromCanvasToRGBInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info) static inline UInt8 CGGI_ConvertBWPixelToByteGray(UInt32 p) { - return 0xFF - (((p >> 24 & 0xFF) + (p >> 16 & 0xFF) + (p >> 8 & 0xFF)) / 3); + UInt8* lut = getReverseGammaLut(); + + UInt8 r = lut[0xFF - (p >> 24 & 0xFF)]; + UInt8 g = lut[0xFF - (p >> 16 & 0xFF)]; + UInt8 b = lut[0xFF - (p >> 8 & 0xFF)]; + + return ((r + g + b) / 3); } static void