From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: Re: Emacs 22.1 Windows ClearType Support Date: Thu, 22 Nov 2007 23:07:10 +0100 Message-ID: References: <4745FB8F.90304@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1195769250 13973 80.91.229.12 (22 Nov 2007 22:07:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Nov 2007 22:07:30 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, "Ng, Andrew" , Emacs Devel To: "Jason Rumney" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 22 23:07:37 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IvKCt-0005iz-3Q for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Nov 2007 23:07:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IvKCe-0007na-TD for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 Nov 2007 17:07:20 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IvKCY-0007n7-Hn for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2007 17:07:14 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IvKCW-0007mv-R4 for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2007 17:07:14 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IvKCW-0007mr-Mb for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2007 17:07:12 -0500 Original-Received: from nz-out-0506.google.com ([64.233.162.237]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IvKCW-0001Pj-5P for bug-gnu-emacs@gnu.org; Thu, 22 Nov 2007 17:07:12 -0500 Original-Received: by nz-out-0506.google.com with SMTP id f1so2331632nzc for ; Thu, 22 Nov 2007 14:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=MlPe/m648Izq/huGX65SzvEQAAOFmHKi1FMahdGKdIA=; b=McHnvILScDpZiLXZxQGf42IssVX6uD9c59ukhmiztjLenS4soY7DkbQHhhnEG6I7/uz4/JFbCAaV+CiaiRvF6VQKPC8cSyzLBiubpDpYi5x0m6rWuaP8y4Qv+GMRpXLVOzb8aDPG9Nu3r9QnKlj1asP6SZz9tYFn3YoCT8cgXcE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ePDiXzod2Sfr/Oi1xFTE6hhnEAwGMO5nZUb3exKkRPbBclsvczxruTm/fAqCUxn6bTKnWMnCMTqGpIQLhbg8uTNDYtgUhiuVDqN4CroPuQSI0PMeCHd05X1cv145iyc85aVAsHYpK2Umlgn4bsIGTRDHQD9jFvoMAq2RPAYOnRI= Original-Received: by 10.142.142.16 with SMTP id p16mr2509755wfd.1195769230983; Thu, 22 Nov 2007 14:07:10 -0800 (PST) Original-Received: by 10.142.153.11 with HTTP; Thu, 22 Nov 2007 14:07:10 -0800 (PST) In-Reply-To: <4745FB8F.90304@gnu.org> Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:17047 gmane.emacs.devel:83906 Archived-At: On Nov 22, 2007 10:58 PM, Jason Rumney 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); } }