unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* "Bold" effect when anti-aliased glyphs are overwritten
@ 2008-05-27 17:51 Chong Yidong
  2008-05-27 21:09 ` Chong Yidong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chong Yidong @ 2008-05-27 17:51 UTC (permalink / raw)
  To: emacs-devel

I've been noticing that glyphs near the cursor occasionally become
"bold" for no reason.  Here's a way to reproduce it:

(defun glyph-test ()
  (interactive)
  (switch-to-buffer "*Test*")
  (erase-buffer)
  (insert "\n ABC")
  (goto-char (point-min)))

M-x glyph-test RET
[down]

The first glyph on the second line, displaying the character "A", now
becomes a little bolder.  Now do

[up]
[down]

Each time, the "A" gets bolder and bolder.

This might depend on the exact font you use (mine is Mono-10).

The reason this happens is that when the redisplay engine calls
draw_glyphs to draw certain glyphs, such as the cursor glyph,
neighboring glyphs are redrawn if there is a left or right overhang
(xdisp.c:19929).

Currently, the foreground of these redrawn glyphs is drawn directly
without erasing the existing glyph.  This is because we generally don't
want to redraw the background, since that might in turn overwrite THIS
glyph's neighbors.  Without anti-aliasing, this procedure is obviously
unproblematic.

With anti-aliasing, it doesn't work well.  Apparently, during the
anti-aliasing calculation, the entire existing glyph---including the
glyph foreground---is treated as the "background".  Thus, the
anti-aliased parts of the foreground character becomes more and more
prominent, and eventually saturates completely.

Does anyone have any ideas for fixing this?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Bold" effect when anti-aliased glyphs are overwritten
  2008-05-27 17:51 "Bold" effect when anti-aliased glyphs are overwritten Chong Yidong
@ 2008-05-27 21:09 ` Chong Yidong
  2008-05-28  8:49   ` Stephen Berman
  2008-05-27 21:18 ` Jason Rumney
  2008-05-28  0:30 ` Kenichi Handa
  2 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2008-05-27 21:09 UTC (permalink / raw)
  To: emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

> I've been noticing that glyphs near the cursor occasionally become
> "bold" for no reason.
>
> The reason this happens is that when the redisplay engine calls
> draw_glyphs to draw certain glyphs, such as the cursor glyph,
> neighboring glyphs are redrawn if there is a left or right overhang
> (xdisp.c:19929).
>
> With anti-aliasing, it doesn't work well.  Apparently, during the
> anti-aliasing calculation, the entire existing glyph---including the
> glyph foreground---is treated as the "background".  Thus, the
> anti-aliased parts of the foreground character becomes more and more
> prominent, and eventually saturates completely.

I've checked in a fix into CVS.  Please let me know if it causes any
problems.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Bold" effect when anti-aliased glyphs are overwritten
  2008-05-27 17:51 "Bold" effect when anti-aliased glyphs are overwritten Chong Yidong
  2008-05-27 21:09 ` Chong Yidong
@ 2008-05-27 21:18 ` Jason Rumney
  2008-05-27 21:21   ` Chong Yidong
  2008-05-28  0:30 ` Kenichi Handa
  2 siblings, 1 reply; 7+ messages in thread
From: Jason Rumney @ 2008-05-27 21:18 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

Chong Yidong wrote:
> Currently, the foreground of these redrawn glyphs is drawn directly
> without erasing the existing glyph.  This is because we generally don't
> want to redraw the background, since that might in turn overwrite THIS
> glyph's neighbors.  Without anti-aliasing, this procedure is obviously
> unproblematic.
>   
The usual way to solve such problems is to use clipping to only erase 
and draw the parts of the neighboring glyphs that need redrawing.
I thought I had seen such code when porting the new font backend to 
Windows, but perhaps I am misremembering.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Bold" effect when anti-aliased glyphs are overwritten
  2008-05-27 21:18 ` Jason Rumney
@ 2008-05-27 21:21   ` Chong Yidong
  2008-05-28  2:21     ` Kenichi Handa
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2008-05-27 21:21 UTC (permalink / raw)
  To: Jason Rumney; +Cc: emacs-devel

Jason Rumney <jasonr@gnu.org> writes:

> The usual way to solve such problems is to use clipping to only erase
> and draw the parts of the neighboring glyphs that need redrawing.
> I thought I had seen such code when porting the new font backend to
> Windows, but perhaps I am misremembering.

Yeah, it turned out to be a bug in x_draw_glyph_string; the clipping
mask was not being used.  I've changed xterm.c; could you take a look at
w32term.c and see if it also needs fixing?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Bold" effect when anti-aliased glyphs are overwritten
  2008-05-27 17:51 "Bold" effect when anti-aliased glyphs are overwritten Chong Yidong
  2008-05-27 21:09 ` Chong Yidong
  2008-05-27 21:18 ` Jason Rumney
@ 2008-05-28  0:30 ` Kenichi Handa
  2 siblings, 0 replies; 7+ messages in thread
From: Kenichi Handa @ 2008-05-28  0:30 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

In article <87ve0zmy8p.fsf@stupidchicken.com>, Chong Yidong <cyd@stupidchicken.com> writes:

> I've been noticing that glyphs near the cursor occasionally become
> "bold" for no reason.  Here's a way to reproduce it:

I've noticed it too.  I think the problem is because Xft
font-backend fails to redraw background before drawing
characters for anti-aliased font.  But, I have not yet found
why that happens.

---
Kenichi Handa
handa@ni.aist.go.jp




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Bold" effect when anti-aliased glyphs are overwritten
  2008-05-27 21:21   ` Chong Yidong
@ 2008-05-28  2:21     ` Kenichi Handa
  0 siblings, 0 replies; 7+ messages in thread
From: Kenichi Handa @ 2008-05-28  2:21 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel, jasonr

In article <87zlqbxx2t.fsf@stupidchicken.com>, Chong Yidong <cyd@stupidchicken.com> writes:

> Yeah, it turned out to be a bug in x_draw_glyph_string; the clipping
> mask was not being used.  I've changed xterm.c; could you take a look at
> w32term.c and see if it also needs fixing?

Thank you for fixing it!

---
Kenichi Handa
handa@ni.aist.go.jp




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Bold" effect when anti-aliased glyphs are overwritten
  2008-05-27 21:09 ` Chong Yidong
@ 2008-05-28  8:49   ` Stephen Berman
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Berman @ 2008-05-28  8:49 UTC (permalink / raw)
  To: emacs-devel

On Tue, 27 May 2008 17:09:29 -0400 Chong Yidong <cyd@stupidchicken.com> wrote:

> Chong Yidong <cyd@stupidchicken.com> writes:
>
>> I've been noticing that glyphs near the cursor occasionally become
>> "bold" for no reason.
>>
>> The reason this happens is that when the redisplay engine calls
>> draw_glyphs to draw certain glyphs, such as the cursor glyph,
>> neighboring glyphs are redrawn if there is a left or right overhang
>> (xdisp.c:19929).
>>
>> With anti-aliasing, it doesn't work well.  Apparently, during the
>> anti-aliasing calculation, the entire existing glyph---including the
>> glyph foreground---is treated as the "background".  Thus, the
>> anti-aliased parts of the foreground character becomes more and more
>> prominent, and eventually saturates completely.
>
> I've checked in a fix into CVS.  Please let me know if it causes any
> problems.

It fixes the cases I have encountered.  Thanks!

Steve Berman





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-05-28  8:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-27 17:51 "Bold" effect when anti-aliased glyphs are overwritten Chong Yidong
2008-05-27 21:09 ` Chong Yidong
2008-05-28  8:49   ` Stephen Berman
2008-05-27 21:18 ` Jason Rumney
2008-05-27 21:21   ` Chong Yidong
2008-05-28  2:21     ` Kenichi Handa
2008-05-28  0:30 ` Kenichi Handa

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).