Subject: bug#33864: Acknowledgement (27.0.50; Display corruption with "small" font size when something is in the fringe)

From: Alan Third <[email-masked]>
Date: Thu, 27 Dec 2018 16:30:11 +0000

On Thu, Dec 27, 2018 at 09:45:57AM -0600, Dale Sedivec wrote:
> You would probably know better than I would, but the only possible
> relevant differences I can think of are:
> 
> * I'm using a smaller font size
> * I'm using a Retina (i.e. scaled) display
> * I'm using macOS 10.13.6

These are all the same, but...

> I am attaching the Elisp script I used to reproduce this problem while
> bisecting, loaded like:
> 
>       nextstep/Emacs.app/Contents/MacOS/Emacs -Q --load repro.el

This reproduces instantly, like you say. Thank you! It looks to me
like the fringe background colour is being drawn right across the
line, which makes me think that the calculation to work out what to
blank in the fringe is going wrong.

I think that what’s happened is I’ve misunderstood one of the NS
rectangle function’s descriptions and assumed it did more error
checking than it does. It looks like the fix is simply to check that
the area that’s to be cleared is actually a legitimate rectangle.

Patch attached.
-- 
Alan Third
>From 3d67a10859d68934ff520eeaa660f5e3c55c2c5b Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Thu, 27 Dec 2018 16:23:32 +0000
Subject: [PATCH] Fix NS fringe bitmap drawing bug (bug#33864)

* src/nsterm.m (ns_draw_fringe_bitmap): Check the rectangle to clear
correctly.
---
 src/nsterm.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 6c285f0abb..a624f62817 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3062,7 +3062,7 @@ so some key presses (TAB) are swallowed by the system.  */
   /* Work out the rectangle we will need to clear.  Because we're
      compositing rather than blitting, we need to clear the area under
      the image regardless of anything else.  */
-  if (!p->overlay_p)
+  if (p->bx >= 0 && !p->overlay_p)
     {
       clearRect = NSMakeRect (p->bx, p->by, p->nx, p->ny);
       clearRect = NSUnionRect (clearRect, imageRect);
-- 
2.19.1