unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: emacs-devel@gnu.org
Subject: Re: Patch for Mac OS X Text Drawing
Date: Fri, 21 Jan 2005 16:57:51 +0900	[thread overview]
Message-ID: <wlzmz3jjsw.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <wlhdldr65c.wl%mituharu@math.s.chiba-u.ac.jp> <wzzmz6iw47.fsf@ordesa.local>

>>>>> On Wed, 19 Jan 2005 20:48:47 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:

>> I had hoped that this would solve the MacOSX bug where if you have
>> some italic text in a window which later is overwritten with spaces

> The X11 version does handle that case.  Basically, we can also do
> the same thing on Mac OS X/Carbon (try the attached patch).  But
> this is not enough when used with anti-aliasing, because text
> drawing is no longer idempotent: if the same text is drawn several
> times onto the same place, it gets thicker.

The patch below works for me.  Carbon Emacs users can test it with the
previously posted macterm.c patch.  (Note that the macterm.c patch is
experimental, and only works for one-byte fonts.)

Could someone check if the following change makes sense?

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

Index: src/dispextern.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispextern.h,v
retrieving revision 1.192
diff -c -r1.192 dispextern.h
*** src/dispextern.h	10 Jan 2005 13:30:46 -0000	1.192
--- src/dispextern.h	21 Jan 2005 05:03:17 -0000
***************
*** 1193,1198 ****
--- 1193,1203 ----
    /* Slice */
    struct glyph_slice slice;
  
+   /* Non-null means the horizontal clipping region starts from the
+      left edge of *clip_head, and ends with the right edge of
+      *clip_tail, not including their overhangs.  */
+   struct glyph_string *clip_head, *clip_tail;
+ 
    struct glyph_string *next, *prev;
  };
  
Index: src/xdisp.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v
retrieving revision 1.966
diff -c -r1.966 xdisp.c
*** src/xdisp.c	19 Jan 2005 10:05:28 -0000	1.966
--- src/xdisp.c	21 Jan 2005 05:03:18 -0000
***************
*** 1776,1781 ****
--- 1776,1799 ----
        r.height = s->row->visible_height;
      }
  
+   if (s->clip_head)
+     if (r.x < s->clip_head->x)
+       {
+ 	if (r.width >= s->clip_head->x - r.x)
+ 	  r.width -= s->clip_head->x - r.x;
+ 	else
+ 	  r.width = 0;
+ 	r.x = s->clip_head->x;
+       }
+   if (s->clip_tail)
+     if (r.x + r.width > s->clip_tail->x + s->clip_tail->width)
+       {
+ 	if (s->clip_tail->x + s->clip_tail->width >= r.x)
+ 	  r.width = s->clip_tail->x + s->clip_tail->width - r.x;
+ 	else
+ 	  r.width = 0;
+       }
+ 
    /* If S draws overlapping rows, it's sufficient to use the top and
       bottom of the window for clipping because this glyph string
       intentionally draws over other lines.  */
***************
*** 18269,18274 ****
--- 18287,18293 ----
      {
        int dummy_x = 0;
        struct glyph_string *h, *t;
+       struct glyph_string *clip_head = NULL, *clip_tail = NULL;
  
        /* Compute overhangs for all glyph strings.  */
        if (rif->compute_glyph_string_overhangs)
***************
*** 18289,18294 ****
--- 18308,18314 ----
  	  start = i;
  	  compute_overhangs_and_x (t, head->x, 1);
  	  prepend_glyph_string_lists (&head, &tail, h, t);
+ 	  clip_head = head;
  	}
  
        /* Prepend glyph strings for glyphs in front of the first glyph
***************
*** 18301,18306 ****
--- 18321,18327 ----
        i = left_overwriting (head);
        if (i >= 0)
  	{
+ 	  clip_head = head;
  	  BUILD_GLYPH_STRINGS (i, start, h, t,
  			       DRAW_NORMAL_TEXT, dummy_x, last_x);
  	  for (s = h; s; s = s->next)
***************
*** 18320,18325 ****
--- 18341,18347 ----
  			       DRAW_NORMAL_TEXT, x, last_x);
  	  compute_overhangs_and_x (h, tail->x + tail->width, 0);
  	  append_glyph_string_lists (&head, &tail, h, t);
+ 	  clip_tail = tail;
  	}
  
        /* Append glyph strings for glyphs following the last glyph
***************
*** 18330,18335 ****
--- 18352,18358 ----
        i = right_overwriting (tail);
        if (i >= 0)
  	{
+ 	  clip_tail = tail;
  	  BUILD_GLYPH_STRINGS (end, i, h, t,
  			       DRAW_NORMAL_TEXT, x, last_x);
  	  for (s = h; s; s = s->next)
***************
*** 18337,18342 ****
--- 18360,18371 ----
  	  compute_overhangs_and_x (h, tail->x + tail->width, 0);
  	  append_glyph_string_lists (&head, &tail, h, t);
  	}
+       if (clip_head || clip_tail)
+ 	for (s = head; s; s = s->next)
+ 	  {
+ 	    s->clip_head = clip_head;
+ 	    s->clip_tail = clip_tail;
+ 	  }
      }
  
    /* Draw all strings.  */

  reply	other threads:[~2005-01-21  7:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-14 20:39 Patch for Mac OS X Text Drawing Arthur G.P. Schuster
2005-01-16  0:39 ` Steven Tamm
2005-01-16  8:04   ` Arthur G.P. Schuster
2005-01-17  3:18   ` YAMAMOTO Mitsuharu
2005-01-17  5:31     ` Steven Tamm
2005-01-17 11:21       ` YAMAMOTO Mitsuharu
2005-01-18 15:40   ` Piet van Oostrum
2005-01-19 11:48     ` YAMAMOTO Mitsuharu
2005-01-21  7:57       ` YAMAMOTO Mitsuharu [this message]
2005-01-22  2:52         ` Richard Stallman
2005-01-22  3:47           ` YAMAMOTO Mitsuharu
2005-01-22  4:55             ` Kenichi Handa
2005-01-22  5:49               ` YAMAMOTO Mitsuharu
     [not found]         ` <200501210353.j0L3rbj16707@church.math.s.chiba-u.ac.jp>
2005-01-24  9:36           ` YAMAMOTO Mitsuharu
2005-01-24 10:08             ` Kim F. Storm
2005-01-24 11:15               ` YAMAMOTO Mitsuharu
2005-01-24 18:00                 ` Steven Tamm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wlzmz3jjsw.wl%mituharu@math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).