From 32003f8402e5b8acde66b481f4c12260a638d9dd Mon Sep 17 00:00:00 2001 From: Eric Branlund Date: Wed, 27 Nov 2019 16:05:50 -0800 Subject: [PATCH 1/2] Use less screen real estate for each grid location since feedback on the rendering change to 4.2.0 was that it made text harder to read and took up too much space. --- src/main-cocoa.m | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main-cocoa.m b/src/main-cocoa.m index 206ca6a1..410272ab 100644 --- a/src/main-cocoa.m +++ b/src/main-cocoa.m @@ -786,18 +786,27 @@ - (void)updateGlyphInfo } /* - * Record the ascender and descender. Adjust both by 0.5 pixel to leave - * space for antialiasing/subpixel positioning. + * Record the ascender and descender. Some fonts, for instance DIN + * Condensed and Rockwell in 10.14, the ascent on '@' exceeds that + * reported by [screenFont ascender]. Get the overall bounding box + * for the glyphs and use that instead of the ascender and descender + * values if the bounding box result extends farther from the baseline. */ - fontAscender = [screenFont ascender] + 0.5; - fontDescender = [screenFont descender] - 0.5; + CGRect bounds = CTFontGetBoundingRectsForGlyphs((CTFontRef) screenFont, kCTFontHorizontalOrientation, glyphArray, NULL, GLYPH_COUNT); + fontAscender = [screenFont ascender]; + if (fontAscender < bounds.origin.y + bounds.size.height) { + fontAscender = bounds.origin.y + bounds.size.height; + } + fontDescender = [screenFont descender]; + if (fontDescender > bounds.origin.y) { + fontDescender = bounds.origin.y; + } /* - * Record the tile size. Add one to the median advance to leave space - * for antialiasing/subpixel positioning. Round both values up to - * have tile boundaries match pixel boundaries. + * Record the tile size. Round both values up to have tile boundaries + * match pixel boundaries. */ - tileSize.width = ceil(medianAdvance + 1.); + tileSize.width = ceil(medianAdvance); tileSize.height = ceil(fontAscender - fontDescender); /* @@ -2433,7 +2442,7 @@ static void Term_xtra_cocoa_fresh(AngbandContext* angbandContext) graf_height = 0; alphablend = 0; } - + CGContextRef ctx = [angbandContext lockFocus]; if (angbandContext->changes->has_text || -- 2.21.0 (Apple Git-122.2) From 1bd9ba7973b55600774c3723ea1e99446a52025b Mon Sep 17 00:00:00 2001 From: Eric Branlund Date: Wed, 27 Nov 2019 22:48:07 -0800 Subject: [PATCH 2/2] Updated comment about GLYPH_COUNT. --- src/main-cocoa.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main-cocoa.m b/src/main-cocoa.m index 410272ab..21f62ff8 100644 --- a/src/main-cocoa.m +++ b/src/main-cocoa.m @@ -346,9 +346,10 @@ static int resize_pending_changes(struct PendingChanges* pc, int nrow) /* The max number of glyphs we support. Currently this only affects - * updateGlyphInfo() for the calculation of the tile size (the glyphArray and - * glyphWidths members of AngbandContext are only used in updateGlyphInfo()). - * The rendering in drawWChar will work for glyphs not in updateGlyphInfo()'s + * updateGlyphInfo() for the calculation of the tile size, fontAscender, + * fontDescender, ncol_pre, and ncol_post (the glyphArray and glyphWidths + * members of AngbandContext are only used in updateGlyphInfo()). The + * rendering in drawWChar will work for glyphs not in updateGlyphInfo()'s * set. */ #define GLYPH_COUNT 256 -- 2.21.0 (Apple Git-122.2)