unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Emacs 22.1 Windows ClearType Support
       [not found] <A69AA663CE9BBC44AE1DA72483DE15DE09AACFEB@HQ-MAIL3.ptcnet.ptc.com>
@ 2007-11-22 21:39 ` Jason Rumney
  2007-11-22 21:43 ` Juanma Barranquero
  2007-11-23  4:35 ` Richard Stallman
  2 siblings, 0 replies; 10+ messages in thread
From: Jason Rumney @ 2007-11-22 21:39 UTC (permalink / raw)
  To: Emacs Devel

Ng, Andrew wrote:
> I have been having a go at fixing up the issues related to ClearType in
> Emacs 22.1.
>   

I have requested an assignment or disclaimer for this change.

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

* Re: Emacs 22.1 Windows ClearType Support
       [not found] <A69AA663CE9BBC44AE1DA72483DE15DE09AACFEB@HQ-MAIL3.ptcnet.ptc.com>
  2007-11-22 21:39 ` Emacs 22.1 Windows ClearType Support Jason Rumney
@ 2007-11-22 21:43 ` Juanma Barranquero
  2007-11-22 21:55   ` Drew Adams
  2007-11-22 21:58   ` Jason Rumney
  2007-11-23  4:35 ` Richard Stallman
  2 siblings, 2 replies; 10+ messages in thread
From: Juanma Barranquero @ 2007-11-22 21:43 UTC (permalink / raw)
  To: Ng, Andrew; +Cc: bug-gnu-emacs, Emacs Devel

On Nov 22, 2007 4:51 PM, Ng, Andrew <anng@ptc.com> wrote:

> I have been having a go at fixing up the issues related to ClearType in
> Emacs 22.1.
>
> I think I have pretty much sorted out the major issues and everything
> appears to work fine now. I've tried as much as possible not to alter
> the non-ClearType code path.
>
> I've also added an environment variable "EMACS_CLEARTYPE". If present
> this will disable ClearType if its value is 0 and will enable ClearType
> if its value is non-zero. Otherwise, ClearType is enabled according to
> the system settings.
>
> I've attached a patch file for my changes.
>
> Thank you.
>
> Regards,
>
> Andrew Ng

Here's the patch, adapted to the current trunk.

             Juanma


Index: src/dispnew.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispnew.c,v
retrieving revision 1.398
diff -u -r1.398 dispnew.c
--- src/dispnew.c	21 Nov 2007 03:46:31 -0000	1.398
+++ src/dispnew.c	22 Nov 2007 21:27:53 -0000
@@ -4525,9 +4525,7 @@
 		 taken care of by draw_glyphs.  */
 	      if (overlapping_glyphs_p
 		  && i > 0
-		  && i < current_row->used[TEXT_AREA]
-		  && (current_row->used[TEXT_AREA]
-		      != desired_row->used[TEXT_AREA]))
+		  && i < current_row->used[TEXT_AREA])
 		{
 		  int left, right;

Index: src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.307
diff -u -r1.307 w32fns.c
--- src/w32fns.c	14 Nov 2007 17:33:36 -0000	1.307
+++ src/w32fns.c	22 Nov 2007 21:23:32 -0000
@@ -4571,6 +4571,8 @@
     int codepage;
     int i;

+    const char *env;
+
     if (!fontname || !x_to_w32_font (fontname, &lf))
       return (NULL);

@@ -4582,7 +4584,12 @@
            ended up with. */
       return NULL;

-    lf.lfQuality = DEFAULT_QUALITY;
+#ifndef CLEARTYPE_QUALITY
+#define CLEARTYPE_QUALITY 5
+#endif
+
+    env = getenv ("EMACS_CLEARTYPE");
+    lf.lfQuality = env ? (atoi (env) ? CLEARTYPE_QUALITY :
ANTIALIASED_QUALITY) : DEFAULT_QUALITY;

     font = (XFontStruct *) xmalloc (sizeof (XFontStruct));
     bzero (font, sizeof (*font));
Index: src/w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.276
diff -u -r1.276 w32term.c
--- src/w32term.c	9 Nov 2007 12:19:55 -0000	1.276
+++ src/w32term.c	22 Nov 2007 21:33:15 -0000
@@ -948,7 +948,7 @@
 #endif
 	  if (cleartype_active)
 	    {
-	      /* Cleartype antialiasing causes characters to overhang
+	      /* Cleartype antialiasing can cause characters to overhang
 		 by a pixel on each side compared with what GetCharABCWidths
 		 reports.  */
 	      char_widths.abcA -= 1;
@@ -1086,7 +1086,8 @@
       if (((font->tm.tmPitchAndFamily & TMPF_FIXED_PITCH) != 0)
           /* Some fonts (eg DBCS fonts) are marked as fixed width even
              though they contain characters of different widths. */
-          || (font->tm.tmMaxCharWidth != font->tm.tmAveCharWidth))
+          || (font->tm.tmMaxCharWidth != font->tm.tmAveCharWidth)
+          || cleartype_active)
 	{
 	  /* Font is not fixed pitch, so cache per_char info for the
              ASCII characters.  It would be much more work, and probably
@@ -1483,9 +1484,42 @@
 w32_compute_glyph_string_overhangs (s)
      struct glyph_string *s;
 {
-  /* TODO: Windows does not appear to have a method for
-     getting this info without getting the ABC widths for each
-     individual character and working it out manually. */
+  if (s->cmp == NULL
+      && s->first_glyph->type == CHAR_GLYPH
+      && s->nchars > 0)
+    {
+      XFontStruct *font = s->font;
+      const int    font_type = s->first_glyph->font_type;
+
+      wchar_t  *ws = s->char2b;
+      const int nc = s->nchars;
+      int       i, pos, mn, mx;
+      if (nc == 1)
+        {
+          XCharStruct *pcm = w32_per_char_metric (font, ws, font_type);
+
+          s->right_overhang = pcm->rbearing > pcm->width ?
pcm->rbearing - pcm->width : 0;
+          s->left_overhang  = pcm->lbearing < 0 ? -pcm->lbearing : 0;
+          return;
+        }
+
+      pos = mn = mx = 0;
+      for (i = 0; i < nc; ++i, ++ws)
+        {
+          XCharStruct *pcm = w32_per_char_metric (font, ws, font_type);
+
+          const int rp = pos + pcm->rbearing;
+          const int lp = pos + pcm->lbearing;
+
+          if (rp > mx) mx = rp;
+          if (lp < mn) mn = lp;
+
+          pos += pcm->width;
+        }
+
+      s->right_overhang = mx > pos ? mx - pos : 0;
+      s->left_overhang  = mn < 0 ? -mn : 0;
+    }
 }


@@ -1582,7 +1616,7 @@
 x_draw_glyph_string_foreground (s)
      struct glyph_string *s;
 {
-  int i, x;
+  int i, x, ct_clear = 0;
   HFONT old_font;

   /* If first glyph of S has a left box line, start drawing the text
@@ -1595,6 +1629,11 @@

   if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR))
     SetBkMode (s->hdc, TRANSPARENT);
+  else if (cleartype_active)
+    {
+      ct_clear = 1;
+      SetBkMode (s->hdc, TRANSPARENT);
+    }
   else
     SetBkMode (s->hdc, OPAQUE);

@@ -1632,6 +1671,21 @@
           char1b[i] = XCHAR2B_BYTE2 (&s->char2b[i]);

       /* Draw text with TextOut and friends. */
+      if (ct_clear)
+        {
+          HBRUSH hb;
+          RECT   r;
+
+          r.left = x;
+          r.top  = s->y;
+          r.right  = x + s->background_width;
+          r.bottom = s->y + s->height;
+
+          hb = CreateSolidBrush (s->gc->background);
+          FillRect (s->hdc, &r, hb);
+          DeleteObject (hb);
+        }
+
       w32_text_out (s, x, s->ybase - boff, s->char2b, s->nchars);

       if (s->face->overstrike)
@@ -6292,7 +6346,7 @@
   w32_destroy_fringe_bitmap,
   w32_per_char_metric,
   w32_encode_char,
-  NULL, /* w32_compute_glyph_string_overhangs */
+  w32_compute_glyph_string_overhangs,
   x_draw_glyph_string,
   w32_define_frame_cursor,
   w32_clear_frame_area,
@@ -6592,6 +6646,8 @@
     UINT smoothing_type;
     BOOL smoothing_enabled;

+    const char *env;
+
     /* If using proportional scroll bars, ensure handle is at least 5 pixels;
        otherwise use the fixed height.  */
     vertical_scroll_bar_min_handle = 5;
@@ -6617,11 +6673,13 @@
        the char metric calculations which adds extra pixels to
        compensate for the "sub-pixels" that are not counted by the
        system APIs. */
+    env = getenv ("EMACS_CLEARTYPE");
     cleartype_active =
-      SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &smoothing_enabled, 0)
-      && smoothing_enabled
-      && SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE, 0, &smoothing_type, 0)
-      && smoothing_type == FE_FONTSMOOTHINGCLEARTYPE;
+      env ? (atoi (env) != 0) :
+      (SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &smoothing_enabled, 0)
+       && smoothing_enabled
+       && SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE, 0,
&smoothing_type, 0)
+       && smoothing_type == FE_FONTSMOOTHINGCLEARTYPE);
   }
 }




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

* RE: Emacs 22.1 Windows ClearType Support
  2007-11-22 21:43 ` Juanma Barranquero
@ 2007-11-22 21:55   ` Drew Adams
  2007-11-22 22:06     ` Jason Rumney
  2007-11-22 21:58   ` Jason Rumney
  1 sibling, 1 reply; 10+ messages in thread
From: Drew Adams @ 2007-11-22 21:55 UTC (permalink / raw)
  To: Juanma Barranquero, Ng, Andrew; +Cc: Emacs Devel

I haven't followed the problems reported with ClearType. But IIUC this patch lets you turn ClearType on and off from within Emacs, using an environment variable. If so, that's good.

I find that ClearType is great with Emacs on Windows, but if it presents problems in particular contexts (e.g. particular fonts or whatever), then perhaps it would be worth having a toggle command to flip it?

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

* Re: Emacs 22.1 Windows ClearType Support
  2007-11-22 21:43 ` Juanma Barranquero
  2007-11-22 21:55   ` Drew Adams
@ 2007-11-22 21:58   ` Jason Rumney
  2007-11-22 22:07     ` Juanma Barranquero
  1 sibling, 1 reply; 10+ messages in thread
From: Jason Rumney @ 2007-11-22 21:58 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: bug-gnu-emacs, Ng, Andrew, Emacs Devel

Juanma Barranquero wrote:
> Here's the patch, adapted to the current trunk.
>   

Thanks, but we would want to install this in EMACS_22_RELEASE, or not at
all. When emacs-unicode-2 gets merged with the trunk, then there is a
completely new font backend which already has the Cleartype problems
mostly fixed (mostly, because the cursor is still being drawn with the
old font code, but that will be fixed before Emacs 23 is released).







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

* Re: Emacs 22.1 Windows ClearType Support
  2007-11-22 21:55   ` Drew Adams
@ 2007-11-22 22:06     ` Jason Rumney
  2007-11-22 22:24       ` Ng, Andrew
  0 siblings, 1 reply; 10+ messages in thread
From: Jason Rumney @ 2007-11-22 22:06 UTC (permalink / raw)
  To: Drew Adams; +Cc: Juanma Barranquero, Ng, Andrew, Emacs Devel

Drew Adams wrote:
> I haven't followed the problems reported with ClearType. But IIUC this patch lets you turn ClearType on and off from within Emacs, using an environment variable. If so, that's good.
>
> I find that ClearType is great with Emacs on Windows, but if it presents problems in particular contexts (e.g. particular fonts or whatever), then perhaps it would be worth having a toggle command to flip it?
>   
The new font backend in emacs-unicode-2 lets you override antialiasing
on a case by case basis for each font. I think an environment variable
is the wrong solution for Emacs, and if the patch really fixes the
problems, then any option is unnecessary.

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

* Re: Emacs 22.1 Windows ClearType Support
  2007-11-22 21:58   ` Jason Rumney
@ 2007-11-22 22:07     ` Juanma Barranquero
  0 siblings, 0 replies; 10+ messages in thread
From: Juanma Barranquero @ 2007-11-22 22:07 UTC (permalink / raw)
  To: Jason Rumney; +Cc: bug-gnu-emacs, Ng, Andrew, Emacs Devel

On Nov 22, 2007 10:58 PM, Jason Rumney <jasonr@gnu.org> wrote:

> Thanks, but we would want to install this in EMACS_22_RELEASE, or not at
> all.

OK; here's against EMACS_22_BASE.

             Juanma


Index: src/dispnew.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispnew.c,v
retrieving revision 1.392.2.1
diff -u -r1.392.2.1 dispnew.c
--- src/dispnew.c	25 Jul 2007 05:15:58 -0000	1.392.2.1
+++ src/dispnew.c	22 Nov 2007 22:00:45 -0000
@@ -4522,9 +4522,7 @@
 		 taken care of by draw_glyphs.  */
 	      if (overlapping_glyphs_p
 		  && i > 0
-		  && i < current_row->used[TEXT_AREA]
-		  && (current_row->used[TEXT_AREA]
-		      != desired_row->used[TEXT_AREA]))
+		  && i < current_row->used[TEXT_AREA])
 		{
 		  int left, right;

Index: src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.288.2.10
diff -u -r1.288.2.10 w32fns.c
--- src/w32fns.c	15 Nov 2007 09:33:33 -0000	1.288.2.10
+++ src/w32fns.c	22 Nov 2007 22:00:45 -0000
@@ -4545,6 +4545,8 @@
     int codepage;
     int i;

+    const char *env;
+
     if (!fontname || !x_to_w32_font (fontname, &lf))
       return (NULL);

@@ -4556,7 +4558,12 @@
            ended up with. */
       return NULL;

-    lf.lfQuality = DEFAULT_QUALITY;
+#ifndef CLEARTYPE_QUALITY
+#define CLEARTYPE_QUALITY 5
+#endif
+
+    env = getenv ("EMACS_CLEARTYPE");
+    lf.lfQuality = env ? (atoi (env) ? CLEARTYPE_QUALITY :
ANTIALIASED_QUALITY) : DEFAULT_QUALITY;

     font = (XFontStruct *) xmalloc (sizeof (XFontStruct));
     bzero (font, sizeof (*font));
Index: src/w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.259.2.6
diff -u -r1.259.2.6 w32term.c
--- src/w32term.c	1 Nov 2007 03:45:35 -0000	1.259.2.6
+++ src/w32term.c	22 Nov 2007 22:00:45 -0000
@@ -903,7 +903,7 @@
 #endif
 	  if (cleartype_active)
 	    {
-	      /* Cleartype antialiasing causes characters to overhang
+	      /* Cleartype antialiasing can cause characters to overhang
 		 by a pixel on each side compared with what GetCharABCWidths
 		 reports.  */
 	      char_widths.abcA -= 1;
@@ -1041,7 +1041,8 @@
       if (((font->tm.tmPitchAndFamily & TMPF_FIXED_PITCH) != 0)
           /* Some fonts (eg DBCS fonts) are marked as fixed width even
              though they contain characters of different widths. */
-          || (font->tm.tmMaxCharWidth != font->tm.tmAveCharWidth))
+          || (font->tm.tmMaxCharWidth != font->tm.tmAveCharWidth)
+          || cleartype_active)
 	{
 	  /* Font is not fixed pitch, so cache per_char info for the
              ASCII characters.  It would be much more work, and probably
@@ -1437,9 +1438,42 @@
 w32_compute_glyph_string_overhangs (s)
      struct glyph_string *s;
 {
-  /* TODO: Windows does not appear to have a method for
-     getting this info without getting the ABC widths for each
-     individual character and working it out manually. */
+  if (s->cmp == NULL
+      && s->first_glyph->type == CHAR_GLYPH
+      && s->nchars > 0)
+    {
+      XFontStruct *font = s->font;
+      const int    font_type = s->first_glyph->font_type;
+
+      wchar_t  *ws = s->char2b;
+      const int nc = s->nchars;
+      int       i, pos, mn, mx;
+      if (nc == 1)
+        {
+          XCharStruct *pcm = w32_per_char_metric (font, ws, font_type);
+
+          s->right_overhang = pcm->rbearing > pcm->width ?
pcm->rbearing - pcm->width : 0;
+          s->left_overhang  = pcm->lbearing < 0 ? -pcm->lbearing : 0;
+          return;
+        }
+
+      pos = mn = mx = 0;
+      for (i = 0; i < nc; ++i, ++ws)
+        {
+          XCharStruct *pcm = w32_per_char_metric (font, ws, font_type);
+
+          const int rp = pos + pcm->rbearing;
+          const int lp = pos + pcm->lbearing;
+
+          if (rp > mx) mx = rp;
+          if (lp < mn) mn = lp;
+
+          pos += pcm->width;
+        }
+
+      s->right_overhang = mx > pos ? mx - pos : 0;
+      s->left_overhang  = mn < 0 ? -mn : 0;
+    }
 }


@@ -1536,7 +1570,7 @@
 x_draw_glyph_string_foreground (s)
      struct glyph_string *s;
 {
-  int i, x;
+  int i, x, ct_clear = 0;
   HFONT old_font;

   /* If first glyph of S has a left box line, start drawing the text
@@ -1549,6 +1583,11 @@

   if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR))
     SetBkMode (s->hdc, TRANSPARENT);
+  else if (cleartype_active)
+    {
+      ct_clear = 1;
+      SetBkMode (s->hdc, TRANSPARENT);
+    }
   else
     SetBkMode (s->hdc, OPAQUE);

@@ -1586,6 +1625,21 @@
           char1b[i] = XCHAR2B_BYTE2 (&s->char2b[i]);

       /* Draw text with TextOut and friends. */
+      if (ct_clear)
+        {
+          HBRUSH hb;
+          RECT   r;
+
+          r.left = x;
+          r.top  = s->y;
+          r.right  = x + s->background_width;
+          r.bottom = s->y + s->height;
+
+          hb = CreateSolidBrush (s->gc->background);
+          FillRect (s->hdc, &r, hb);
+          DeleteObject (hb);
+        }
+
       w32_text_out (s, x, s->ybase - boff, s->char2b, s->nchars);

       if (s->face->overstrike)
@@ -6357,7 +6411,7 @@
   w32_destroy_fringe_bitmap,
   w32_per_char_metric,
   w32_encode_char,
-  NULL, /* w32_compute_glyph_string_overhangs */
+  w32_compute_glyph_string_overhangs,
   x_draw_glyph_string,
   w32_define_frame_cursor,
   w32_clear_frame_area,
@@ -6455,6 +6509,8 @@
     UINT smoothing_type;
     BOOL smoothing_enabled;

+    const char *env;
+
     /* If using proportional scroll bars, ensure handle is at least 5 pixels;
        otherwise use the fixed height.  */
     vertical_scroll_bar_min_handle = 5;
@@ -6480,11 +6536,13 @@
        the char metric calculations which adds extra pixels to
        compensate for the "sub-pixels" that are not counted by the
        system APIs. */
+    env = getenv ("EMACS_CLEARTYPE");
     cleartype_active =
-      SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &smoothing_enabled, 0)
-      && smoothing_enabled
-      && SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE, 0, &smoothing_type, 0)
-      && smoothing_type == FE_FONTSMOOTHINGCLEARTYPE;
+      env ? (atoi (env) != 0) :
+      (SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &smoothing_enabled, 0)
+       && smoothing_enabled
+       && SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE, 0,
&smoothing_type, 0)
+       && smoothing_type == FE_FONTSMOOTHINGCLEARTYPE);
   }
 }




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

* RE: Emacs 22.1 Windows ClearType Support
  2007-11-22 22:06     ` Jason Rumney
@ 2007-11-22 22:24       ` Ng, Andrew
  2007-11-22 22:47         ` Drew Adams
  0 siblings, 1 reply; 10+ messages in thread
From: Ng, Andrew @ 2007-11-22 22:24 UTC (permalink / raw)
  To: Jason Rumney, Drew Adams; +Cc: Juanma Barranquero, Emacs Devel

Part of the reason that I needed a way to enable ClearType in Emacs is that by default I actually have ClearType disabled on my system. The reason for this is that I have a two LCD monitor setup but unfortunately, the two LCD monitors RGB order do not match. This effectively means that ClearType looks great on one display and not so good on the other. That's one thing Microsoft obviously didn't consider when implementing the ClearType support.
 
Because I mostly use Emacs on the one LCD monitor, I explicitly enable ClearType in Emacs.
 
Cheers,
 
Andrew

________________________________

From: Jason Rumney [mailto:jasonr@gnu.org]
Sent: Thu 22/11/2007 22:06
To: Drew Adams
Cc: Juanma Barranquero; Ng, Andrew; Emacs Devel
Subject: Re: Emacs 22.1 Windows ClearType Support



Drew Adams wrote:
> I haven't followed the problems reported with ClearType. But IIUC this patch lets you turn ClearType on and off from within Emacs, using an environment variable. If so, that's good.
>
> I find that ClearType is great with Emacs on Windows, but if it presents problems in particular contexts (e.g. particular fonts or whatever), then perhaps it would be worth having a toggle command to flip it?
>  
The new font backend in emacs-unicode-2 lets you override antialiasing
on a case by case basis for each font. I think an environment variable
is the wrong solution for Emacs, and if the patch really fixes the
problems, then any option is unnecessary.

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

* RE: Emacs 22.1 Windows ClearType Support
  2007-11-22 22:24       ` Ng, Andrew
@ 2007-11-22 22:47         ` Drew Adams
  0 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2007-11-22 22:47 UTC (permalink / raw)
  To: Emacs Devel; +Cc: Ng, Andrew

> Part of the reason that I needed a way to enable ClearType in
> Emacs is that by default I actually have ClearType disabled on my
> system. The reason for this is that I have a two LCD monitor
> setup but unfortunately, the two LCD monitors RGB order do not
> match. This effectively means that ClearType looks great on one
> display and not so good on the other. That's one thing Microsoft
> obviously didn't consider when implementing the ClearType support.
>
> Because I mostly use Emacs on the one LCD monitor, I explicitly
> enable ClearType in Emacs.

This won't help with tuning two LCDs differently, but it might help to know
that there is a simple $free tool for tuning ClearType.

Download: http://www.microsoft.com/typography/ClearTypePowerToy.mspx
Wikipedia article: http://en.wikipedia.org/wiki/ClearType

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

* Re: Emacs 22.1 Windows ClearType Support
       [not found] <A69AA663CE9BBC44AE1DA72483DE15DE09AACFEB@HQ-MAIL3.ptcnet.ptc.com>
  2007-11-22 21:39 ` Emacs 22.1 Windows ClearType Support Jason Rumney
  2007-11-22 21:43 ` Juanma Barranquero
@ 2007-11-23  4:35 ` Richard Stallman
  2 siblings, 0 replies; 10+ messages in thread
From: Richard Stallman @ 2007-11-23  4:35 UTC (permalink / raw)
  To: emacs-devel; +Cc: Ng, Andrew

If people decide to install this, we should ask Andrew to sign
a disclaimer for it.

Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C82D1F.7AB72653"
Date: Thu, 22 Nov 2007 10:51:24 -0500
Message-ID: <A69AA663CE9BBC44AE1DA72483DE15DE09AACFEB@HQ-MAIL3.ptcnet.ptc.com>
Thread-Topic: Emacs 22.1 Windows ClearType Support
Thread-Index: AcgtH4jh8q9WrvztS6uHkPEgf4wmYg==
From: "Ng, Andrew" <anng@ptc.com>
To: <bug-gnu-emacs@gnu.org>
Subject: Emacs 22.1 Windows ClearType Support

This is a multi-part message in MIME format.

------_=_NextPart_001_01C82D1F.7AB72653
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I have been having a go at fixing up the issues related to ClearType in
Emacs 22.1.

I think I have pretty much sorted out the major issues and everything
appears to work fine now. I've tried as much as possible not to alter
the non-ClearType code path.

I've also added an environment variable "EMACS_CLEARTYPE". If present
this will disable ClearType if its value is 0 and will enable ClearType
if its value is non-zero. Otherwise, ClearType is enabled according to
the system settings.

I've attached a patch file for my changes.

Thank you.

Regards,

Andrew Ng

------_=_NextPart_001_01C82D1F.7AB72653
Content-Type: application/octet-stream;
	name="patchfile"
Content-Transfer-Encoding: base64
Content-Description: patchfile
Content-Disposition: attachment;
	filename="patchfile"

ZGlmZiAtdSBlbWFjcy0yMi4xLW9yaWcvc3JjL2Rpc3BuZXcuYyBlbWFjcy0yMi4xL3NyYy9kaXNw
bmV3LmMKLS0tIGVtYWNzLTIyLjEtb3JpZy9zcmMvZGlzcG5ldy5jCTIwMDctMDQtMTYgMTc6MjE6
MTguMDAwMDAwMDAwICswMTAwCisrKyBlbWFjcy0yMi4xL3NyYy9kaXNwbmV3LmMJMjAwNy0xMS0y
MiAxNDoyNjo0NC4xODc1MDAwMDAgKzAwMDAKQEAgLTQ1M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AgICYmIHMt
PmZpcnN0X2dseXBoLT50eXBlID09IENIQVJfR0xZUEgKKyAgICAgICYmIHMtPm5jaGFycyA+IDAp
CisgICAgeworICAgICAgWEZvbnRTdHJ1Y3QgKmZvbnQgPSBzLT5mb250OworICAgICAgY29uc3Qg
aW50ICAgIGZvbnRfdHlwZSA9IHMtPmZpcnN0X2dseXBoLT5mb250X3R5cGU7CisKKyAgICAgIHdj
aGFyX3QgICp3cyA9IHMtPmNoYXIyYjsKKyAgICAgIGNvbnN0IGludCBuYyA9IHMtPm5jaGFyczsK
KyAgICAgIGludCAgICAgICBpLCBwb3MsIG1uLCBteDsKKyAgICAgIGlmIChuYyA9PSAxKQorICAg
ICAgICB7CisgICAgICAgICAgWENoYXJTdHJ1Y3QgKnBjbSA9IHczMl9wZXJfY2hhcl9tZXRyaWMg
KGZvbnQsIHdzLCBmb250X3R5cGUpOworCisgICAgICAgICAgcy0+cmlnaHRfb3ZlcmhhbmcgPSBw
Y20tPnJiZWFyaW5nID4gcGNtLT53aWR0aCA/IHBjbS0+cmJlYXJpbmcgLSBwY20tPndpZHRoIDog
MDsKKyAgICAgICAgICBzLT5sZWZ0X292ZXJoYW5nICA9IHBjbS0+bGJlYXJpbmcgPCAwID8gLXBj
bS0+bGJlYXJpbmcgOiAwOworICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorCisgICAgICBw
b3MgPSBtbiA9IG14ID0gMDsKKyAgICAgIGZvciAoaSA9IDA7IGkgPCBuYzsgKytpLCArK3dzKQor
ICAgICAgICB7CisgICAgICAgICAgWENoYXJTdHJ1Y3QgKnBjbSA9IHczMl9wZXJfY2hhcl9tZXRy
aWMgKGZvbnQsIHdzLCBmb250X3R5cGUpOworCisgICAgICAgICAgY29uc3QgaW50IHJwID0gcG9z
ICsgcGNtLT5yYmVhcmluZzsKKyAgICAgICAgICBjb25zdCBpbnQgbHAgPSBwb3MgKyBwY20tPmxi
ZWFyaW5nOworCisgICAgICAgICAgaWYgKHJwID4gbXgpI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A/IChhdG9pKGVudikgIT0gMCkg
OgorICAgICAgICAoU3lzdGVtUGFyYW1ldGVyc0luZm8gKFNQSV9HRVRGT05UU01PT1RISU5HLCAw
LCAmc21vb3RoaW5nX2VuYWJsZWQsIDApCisgICAgICAgICAmJiBzbW9vdGhpbmdfZW5hYmxlZAor
ICAgICAgICAgJiYgU3lzdGVtUGFyYW1ldGVyc0luZm8gKFNQSV9HRVRGT05UU01PT1RISU5HVFlQ
RSwgMCwgJnNtb290aGluZ190eXBlLCAwKQorICAgICAgICAgJiYgc21vb3RoaW5nX3R5cGUgPT0g
RkVfRk9OVFNNT09USElOR0NMRUFSVFlQRSk7CiAgIH0KIH0KIAo=

------_=_NextPart_001_01C82D1F.7AB72653--

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

* Re: Emacs 22.1 Windows ClearType Support
@ 2007-11-23  9:46 Angelo Graziosi
  0 siblings, 0 replies; 10+ messages in thread
From: Angelo Graziosi @ 2007-11-23  9:46 UTC (permalink / raw)
  To: emacs-devel



I have the habit to do a Cygwin build of Emacs-CVS but recently I have
tried this:
ftp://alpha.gnu.org/gnu/auctex/emacs+auctex-w32-2007-07-07.zip, that is a
native Windows build.

Comparing the look of characters, the Windows build looks better than the
Cygwin one: the characters appear antialiased (I have an LCD with
ClearType enabled in Windows XP) while in the Cygwin build they do not
look so well defined.

I ask if one can apply some tricks to have better results also in
the Cygwin build (avoiding GTK that under Cygwin does not work, see
PROBLEMS).


TIA,

   Angelo.


---
http://www.webalice.it/angelo.graziosi

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

end of thread, other threads:[~2007-11-23  9:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <A69AA663CE9BBC44AE1DA72483DE15DE09AACFEB@HQ-MAIL3.ptcnet.ptc.com>
2007-11-22 21:39 ` Emacs 22.1 Windows ClearType Support Jason Rumney
2007-11-22 21:43 ` Juanma Barranquero
2007-11-22 21:55   ` Drew Adams
2007-11-22 22:06     ` Jason Rumney
2007-11-22 22:24       ` Ng, Andrew
2007-11-22 22:47         ` Drew Adams
2007-11-22 21:58   ` Jason Rumney
2007-11-22 22:07     ` Juanma Barranquero
2007-11-23  4:35 ` Richard Stallman
2007-11-23  9:46 Angelo Graziosi

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).