From 886309850fee04db326c09dc2f1af2c00f7e9bb5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Feb 2021 16:08:06 +0530 Subject: [PATCH] Dont add alpha when rendering alpha mask on canvas Instead use the larger of the two alphas. This gives better results for overlapping text, such as the infinite length ligature glyphs used by FiraCode. I dont think adding ever gave better results anyway. --- docs/changelog.rst | 2 +- kitty/fonts.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5896932e1..3adf9b461 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -70,7 +70,7 @@ To update |kitty|, :doc:`follow the instructions `. - Improve handling of infinite length ligatures in newer versions of FiraCode and CascadiaCode. Now such ligatures are detected based on glyph naming - convention, this removes the gap in the ligatures at cell boundaries (:iss:`2695`) + convention. This removes the gap in the ligatures at cell boundaries (:iss:`2695`) 0.19.3 [2020-12-19] diff --git a/kitty/fonts.c b/kitty/fonts.c index 934ee9d24..074f35932 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -667,9 +667,10 @@ render_alpha_mask(uint8_t *alpha_mask, pixel* dest, Region *src_rect, Region *de pixel *d = dest + dest_stride * dr; uint8_t *s = alpha_mask + src_stride * sr; for(size_t sc = src_rect->left, dc = dest_rect->left; sc < src_rect->right && dc < dest_rect->right; sc++, dc++) { - pixel val = d[dc]; + uint8_t src_alpha = d[dc] & 0xff; uint8_t alpha = s[sc]; - d[dc] = 0xffffff00 | MIN(0xffu, alpha + (val & 0xff)); + uint8_t combined_alpha = MAX(alpha, src_alpha); + d[dc] = 0xffffff00 | MIN(0xffu, combined_alpha); } } }