Patch 8.1.1294

7 views
Skip to first unread message

Bram Moolenaar

unread,
May 7, 2019, 4:53:15 PM5/7/19
to vim...@googlegroups.com

Patch 8.1.1294
Problem: MS-Windows: Some fonts return wrong average char width.
Solution: Compute the average ourselves. (Ken Takata, closes #4356)
Files: src/gui_w32.c


*** ../vim-8.1.1293/src/gui_w32.c 2019-04-29 21:46:22.849288641 +0200
--- src/gui_w32.c 2019-05-07 22:50:35.029418835 +0200
***************
*** 1455,1464 ****
HWND hwnd = GetDesktopWindow();
HDC hdc = GetWindowDC(hwnd);
HFONT hfntOld = SelectFont(hdc, (HFONT)font);
TEXTMETRIC tm;

GetTextMetrics(hdc, &tm);
! gui.char_width = tm.tmAveCharWidth + tm.tmOverhang;

gui.char_height = tm.tmHeight + p_linespace;

--- 1455,1470 ----
HWND hwnd = GetDesktopWindow();
HDC hdc = GetWindowDC(hwnd);
HFONT hfntOld = SelectFont(hdc, (HFONT)font);
+ SIZE size;
TEXTMETRIC tm;

GetTextMetrics(hdc, &tm);
! // GetTextMetrics() may not return the right value in tmAveCharWidth
! // for some fonts. Do our own average computation.
! GetTextExtentPoint(hdc,
! "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
! 52, &size);
! gui.char_width = (size.cx / 26 + 1) / 2 + tm.tmOverhang;

gui.char_height = tm.tmHeight + p_linespace;

*** ../vim-8.1.1293/src/version.c 2019-05-07 22:25:23.486167275 +0200
--- src/version.c 2019-05-07 22:52:16.076724322 +0200
***************
*** 769,770 ****
--- 769,772 ----
{ /* Add new patch number below this line */
+ /**/
+ 1294,
/**/

--
No man may purchase alcohol without written consent from his wife.
[real standing law in Pennsylvania, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages