diff options
| author | Tom Seddon | 2013-11-29 13:01:45 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-11-29 13:01:45 +0200 |
| commit | 579ca67bf4c73113aed658f3a954807de47ca3e3 (patch) | |
| tree | 54149e64793d1367625628f6c84238c814b16fd3 | |
| parent | de20f087b85e60b0d5aa899141a3349d4d9da80d (diff) | |
| download | emacs-579ca67bf4c73113aed658f3a954807de47ca3e3.tar.gz emacs-579ca67bf4c73113aed658f3a954807de47ca3e3.zip | |
Fix bug #6364 with slow scrolling on MS-Windows with bitmap fonts.
src/w32font.c (g_b_init_get_char_width_32_w): New static var.
(globals_of_w32font): Zero it out.
(GetCharWidth32W_Proc): New function pointer.
(get_char_width_32_w): New function.
(compute_metrics): If get_glyph_outline_w returns an error, try
get_char_width_32_w before declaring a failure. This avoids
punishing raster (a.k.a. "bitmap") fonts by slowing down
redisplay.
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/w32font.c | 32 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c05845cef71..668bba1e4ed 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,4 +1,13 @@ | |||
| 1 | 2013-11-29 Eli Zaretskii <eliz@gnu.org> | 1 | 2013-11-29 Tom Seddon <emacs@tomseddon.plus.com> (tiny change) |
| 2 | |||
| 3 | * w32font.c (g_b_init_get_char_width_32_w): New static var. | ||
| 4 | (globals_of_w32font): Zero it out. | ||
| 5 | (GetCharWidth32W_Proc): New function pointer. | ||
| 6 | (get_char_width_32_w): New function. | ||
| 7 | (compute_metrics): If get_glyph_outline_w returns an error, try | ||
| 8 | get_char_width_32_w before declaring a failure. This avoids | ||
| 9 | punishing raster (a.k.a. "bitmap") fonts by slowing down | ||
| 10 | redisplay. (Bug#6364). | ||
| 2 | 11 | ||
| 3 | * xdisp.c (clear_mouse_face): Don't invalidate the entire | 12 | * xdisp.c (clear_mouse_face): Don't invalidate the entire |
| 4 | mouse-highlight info, just signal frame_up_to_date_hook that mouse | 13 | mouse-highlight info, just signal frame_up_to_date_hook that mouse |
diff --git a/src/w32font.c b/src/w32font.c index effedfc04e1..923c71b1147 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -149,6 +149,7 @@ static BOOL g_b_init_get_outline_metrics_w; | |||
| 149 | static BOOL g_b_init_get_text_metrics_w; | 149 | static BOOL g_b_init_get_text_metrics_w; |
| 150 | static BOOL g_b_init_get_glyph_outline_w; | 150 | static BOOL g_b_init_get_glyph_outline_w; |
| 151 | static BOOL g_b_init_get_glyph_outline_w; | 151 | static BOOL g_b_init_get_glyph_outline_w; |
| 152 | static BOOL g_b_init_get_char_width_32_w; | ||
| 152 | 153 | ||
| 153 | typedef UINT (WINAPI * GetOutlineTextMetricsW_Proc) ( | 154 | typedef UINT (WINAPI * GetOutlineTextMetricsW_Proc) ( |
| 154 | HDC hdc, | 155 | HDC hdc, |
| @@ -165,6 +166,11 @@ typedef DWORD (WINAPI * GetGlyphOutlineW_Proc) ( | |||
| 165 | DWORD cbBuffer, | 166 | DWORD cbBuffer, |
| 166 | LPVOID lpvBuffer, | 167 | LPVOID lpvBuffer, |
| 167 | const MAT2 *lpmat2); | 168 | const MAT2 *lpmat2); |
| 169 | typedef BOOL (WINAPI * GetCharWidth32W_Proc) ( | ||
| 170 | HDC hdc, | ||
| 171 | UINT uFirstChar, | ||
| 172 | UINT uLastChar, | ||
| 173 | LPINT lpBuffer); | ||
| 168 | 174 | ||
| 169 | /* Several "wide" functions we use to support the font backends are | 175 | /* Several "wide" functions we use to support the font backends are |
| 170 | unavailable on Windows 9X, unless UNICOWS.DLL is installed (their | 176 | 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, | |||
| 274 | lpvBuffer, lpmat2); | 280 | lpvBuffer, lpmat2); |
| 275 | } | 281 | } |
| 276 | 282 | ||
| 283 | static DWORD WINAPI get_char_width_32_w (HDC hdc, UINT uFirstChar, | ||
| 284 | UINT uLastChar, LPINT lpBuffer) | ||
| 285 | { | ||
| 286 | static GetCharWidth32W_Proc s_pfn_Get_Char_Width_32W = NULL; | ||
| 287 | HMODULE hm_unicows = NULL; | ||
| 288 | if (g_b_init_get_char_width_32_w == 0) | ||
| 289 | { | ||
| 290 | g_b_init_get_char_width_32_w = 1; | ||
| 291 | hm_unicows = w32_load_unicows_or_gdi32 (); | ||
| 292 | if (hm_unicows) | ||
| 293 | s_pfn_Get_Char_Width_32W = (GetCharWidth32W_Proc) | ||
| 294 | GetProcAddress (hm_unicows, "GetCharWidth32W"); | ||
| 295 | } | ||
| 296 | eassert (s_pfn_Get_Char_Width_32W != NULL); | ||
| 297 | return s_pfn_Get_Char_Width_32W (hdc, uFirstChar, uLastChar, lpBuffer); | ||
| 298 | } | ||
| 299 | |||
| 277 | static int | 300 | static int |
| 278 | memq_no_quit (Lisp_Object elt, Lisp_Object list) | 301 | memq_no_quit (Lisp_Object elt, Lisp_Object list) |
| 279 | { | 302 | { |
| @@ -2437,6 +2460,7 @@ compute_metrics (HDC dc, struct w32font_info *w32_font, unsigned int code, | |||
| 2437 | GLYPHMETRICS gm; | 2460 | GLYPHMETRICS gm; |
| 2438 | MAT2 transform; | 2461 | MAT2 transform; |
| 2439 | unsigned int options = GGO_METRICS; | 2462 | unsigned int options = GGO_METRICS; |
| 2463 | INT width; | ||
| 2440 | 2464 | ||
| 2441 | if (w32_font->glyph_idx) | 2465 | if (w32_font->glyph_idx) |
| 2442 | options |= GGO_GLYPH_INDEX; | 2466 | options |= GGO_GLYPH_INDEX; |
| @@ -2453,6 +2477,13 @@ compute_metrics (HDC dc, struct w32font_info *w32_font, unsigned int code, | |||
| 2453 | metrics->width = gm.gmCellIncX; | 2477 | metrics->width = gm.gmCellIncX; |
| 2454 | metrics->status = W32METRIC_SUCCESS; | 2478 | metrics->status = W32METRIC_SUCCESS; |
| 2455 | } | 2479 | } |
| 2480 | else if (get_char_width_32_w (dc, code, code, &width) != 0) | ||
| 2481 | { | ||
| 2482 | metrics->lbearing = 0; | ||
| 2483 | metrics->rbearing = width; | ||
| 2484 | metrics->width = width; | ||
| 2485 | metrics->status = W32METRIC_SUCCESS; | ||
| 2486 | } | ||
| 2456 | else | 2487 | else |
| 2457 | metrics->status = W32METRIC_FAIL; | 2488 | metrics->status = W32METRIC_FAIL; |
| 2458 | } | 2489 | } |
| @@ -2727,4 +2758,5 @@ globals_of_w32font (void) | |||
| 2727 | g_b_init_get_outline_metrics_w = 0; | 2758 | g_b_init_get_outline_metrics_w = 0; |
| 2728 | g_b_init_get_text_metrics_w = 0; | 2759 | g_b_init_get_text_metrics_w = 0; |
| 2729 | g_b_init_get_glyph_outline_w = 0; | 2760 | g_b_init_get_glyph_outline_w = 0; |
| 2761 | g_b_init_get_char_width_32_w = 0; | ||
| 2730 | } | 2762 | } |