From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Seddon Newsgroups: gmane.emacs.bugs Subject: bug#6364: [PATCH] Use GetCharABCWidthsFloatW if GetGlyphOutlineW fails. Date: Tue, 26 Nov 2013 00:35:05 +0000 Message-ID: <713BA87B-E38A-4777-B054-E136A7C96EF9@tomseddon.plus.com> References: <8CCD3BEBEE756DD-DB8-DFB9@web-mmc-m08.sysops.aol.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1385426592 25510 80.91.229.3 (26 Nov 2013 00:43:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Nov 2013 00:43:12 +0000 (UTC) To: 6364@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 26 01:43:17 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vl6kH-00029i-3i for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Nov 2013 01:43:17 +0100 Original-Received: from localhost ([::1]:55718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6kG-0003TY-Kd for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Nov 2013 19:43:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6k8-0003TP-BH for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 19:43:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl6k2-0003PA-B5 for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 19:43:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6k2-0003P5-71 for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 19:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vl6k1-0006hT-TN for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 19:43:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <8CCD3BEBEE756DD-DB8-DFB9@web-mmc-m08.sysops.aol.com> Resent-From: Tom Seddon Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Nov 2013 00:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6364 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6364-submit@debbugs.gnu.org id=B6364.138542654625685 (code B ref 6364); Tue, 26 Nov 2013 00:43:01 +0000 Original-Received: (at 6364) by debbugs.gnu.org; 26 Nov 2013 00:42:26 +0000 Original-Received: from localhost ([127.0.0.1]:45161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl6jR-0006gB-Aq for submit@debbugs.gnu.org; Mon, 25 Nov 2013 19:42:25 -0500 Original-Received: from caiajhbdcbef.dreamhost.com ([208.97.132.145]:35339 helo=homiemail-a96.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl6cR-0006Vh-Dn for 6364@debbugs.gnu.org; Mon, 25 Nov 2013 19:35:12 -0500 Original-Received: from homiemail-a96.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a96.g.dreamhost.com (Postfix) with ESMTP id 43B4E3B806C for <6364@debbugs.gnu.org>; Mon, 25 Nov 2013 16:35:10 -0800 (PST) Original-Received: from [192.168.1.101] (tomseddon.plus.com [212.159.116.120]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: tom@ouro.ltd.uk) by homiemail-a96.g.dreamhost.com (Postfix) with ESMTPSA id 582953B8005 for <6364@debbugs.gnu.org>; Mon, 25 Nov 2013 16:35:08 -0800 (PST) X-Mailer: Apple Mail (2.1822) X-Mailman-Approved-At: Mon, 25 Nov 2013 19:42:23 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:80969 Archived-At: Please find below a patch to improve the poor scrolling performance when = using bitmap fonts. #14721 = (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14721) and and 14307 = (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14307) may also be = affected. The patch has been tested against emacs 24.3. It applied = cleanly to git head (22687e54e0e4d7c73c098417478574a55393fe2c) but I = haven't built it. Performance with particularly long lines is still rather poor, but = general responsiveness is much improved. (Once the buffer is fontified, = emacs can now usually keep up if I hold down PgUp, PgDn, C-s, etc.) (I settled on GetCharABCWidthsFloatW because it works for bitmap fonts = and TrueType fonts alike. But the key thing is simply not to create a DC = each time w32font_text_extents is called, so there are various other = functions that could be called instead if preferred.) --Tom =46rom ccedd16f6bd2027145b9e172346d2c3b31c811df Mon Sep 17 00:00:00 2001 From: Tom Seddon Date: Mon, 25 Nov 2013 22:19:47 +0000 Subject: [PATCH] Use GetCharABCWidthsFloatW if GetGlyphOutlineW fails. The previous fallback - which will still be used if GetCharABCWidthsFloatW fails - was to call GetTextExtentPoint32W. This can be rather slow due to having to create a DC for it each time. --- src/w32font.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/w32font.c b/src/w32font.c index 5c5a15c..3577dfa 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -149,6 +149,7 @@ static BOOL g_b_init_get_outline_metrics_w; static BOOL g_b_init_get_text_metrics_w; static BOOL g_b_init_get_glyph_outline_w; static BOOL g_b_init_get_glyph_outline_w; +static BOOL g_b_init_get_char_abc_widths_float_w; =20 typedef UINT (WINAPI * GetOutlineTextMetricsW_Proc) ( HDC hdc, @@ -165,6 +166,11 @@ typedef DWORD (WINAPI * GetGlyphOutlineW_Proc) ( DWORD cbBuffer, LPVOID lpvBuffer, const MAT2 *lpmat2); +typedef BOOL (WINAPI * GetCharABCWidthsFloatW_Proc) ( + HDC hdc, + UINT uFirstChar, + UINT uLastChar, + LPABCFLOAT lpabc); =20 /* Several "wide" functions we use to support the font backends are unavailable on Windows 9X, unless UNICOWS.DLL is installed (their @@ -274,6 +280,23 @@ get_glyph_outline_w (HDC hdc, UINT uChar, UINT = uFormat, LPGLYPHMETRICS lpgm, lpvBuffer, lpmat2); } =20 +static DWORD WINAPI get_char_abc_widths_float_w (HDC hdc, UINT = uFirstChar, + UINT uLastChar, = LPABCFLOAT lpabc) +{ + static GetCharABCWidthsFloatW_Proc s_pfn_Get_Char_ABC_Widths_FloatW =3D= NULL; + HMODULE hm_unicows =3D NULL; + if (g_b_init_get_char_abc_widths_float_w =3D=3D 0) + { + g_b_init_get_char_abc_widths_float_w =3D 1; + hm_unicows =3D w32_load_unicows_or_gdi32 (); + if (hm_unicows) + s_pfn_Get_Char_ABC_Widths_FloatW =3D = (GetCharABCWidthsFloatW_Proc) + GetProcAddress (hm_unicows, "GetCharABCWidthsFloatW"); + } + eassert (s_pfn_Get_Char_ABC_Widths_FloatW !=3D NULL); + return s_pfn_Get_Char_ABC_Widths_FloatW (hdc, uFirstChar, uLastChar, = lpabc); +} + static int memq_no_quit (Lisp_Object elt, Lisp_Object list) { @@ -2438,6 +2461,7 @@ compute_metrics (HDC dc, struct w32font_info = *w32_font, unsigned int code, GLYPHMETRICS gm; MAT2 transform; unsigned int options =3D GGO_METRICS; + ABCFLOAT abc; =20 if (w32_font->glyph_idx) options |=3D GGO_GLYPH_INDEX; @@ -2454,6 +2478,14 @@ compute_metrics (HDC dc, struct w32font_info = *w32_font, unsigned int code, metrics->width =3D gm.gmCellIncX; metrics->status =3D W32METRIC_SUCCESS; } + else if (get_char_abc_widths_float_w (dc, code, code, &abc) !=3D 0) + { + int width =3D (int) (abc.abcfA + abc.abcfB + abc.abcfC); + metrics->lbearing =3D 0; + metrics->rbearing =3D width; + metrics->width =3D width; + metrics->status =3D W32METRIC_SUCCESS; + } else metrics->status =3D W32METRIC_FAIL; } --=20 1.8.1.msysgit.1