From cde69670ba386e83fcc7ae95d400e9a73cf2cbb6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 30 Jun 2019 08:51:35 +0530 Subject: [PATCH] Linux: Fix incorrect scaling for fallback fonts when the font has an underscore that renders out of bounds The calc_cell_height() function should not use underscore heights when called in contexts other than cell metrics calculation. Fixes #1713 --- docs/changelog.rst | 4 ++++ kitty/freetype.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6c33a3651..a4cc6eb46 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -29,6 +29,10 @@ To update |kitty|, :doc:`follow the instructions `. - macOS: Reduce energy consumption when idle by shutting down Apple's display link thread after 30 second of inactivity (:iss:`1763`) +- Linux: Fix incorrect scaling for fallback fonts when the font has an + underscore that renders out of bounds (:iss:`1713`) + + 0.14.2 [2019-06-09] --------------------- diff --git a/kitty/freetype.c b/kitty/freetype.c index 198f737b9..475352b69 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -123,11 +123,15 @@ get_height_for_char(Face *self, char ch) { static inline unsigned int calc_cell_height(Face *self, bool for_metrics) { unsigned int ans = font_units_to_pixels_y(self, self->height); - unsigned int underscore_height = get_height_for_char(self, '_'); - if (for_metrics && global_state.debug_font_fallback && underscore_height > ans) { - printf("Increasing cell height by %u pixels to work around buggy font that renders underscore outside the bounding box\n", underscore_height - ans); + if (for_metrics) { + unsigned int underscore_height = get_height_for_char(self, '_'); + if (underscore_height > ans) { + if (global_state.debug_font_fallback) printf( + "Increasing cell height by %u pixels to work around buggy font that renders underscore outside the bounding box\n", underscore_height - ans); + return underscore_height; + } } - return MAX(ans, underscore_height); + return ans; } static inline bool