0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.1.1294: MS-Windows: Some fonts return wrong average char width

Problem:    MS-Windows: Some fonts return wrong average char width.
Solution:   Compute the average ourselves. (Ken Takata, closes #4356)
This commit is contained in:
Bram Moolenaar
2019-05-07 22:52:50 +02:00
parent fda9784dc9
commit 93d77b2cbe
2 changed files with 9 additions and 1 deletions

View File

@@ -1455,10 +1455,16 @@ GetFontSize(GuiFont font)
HWND hwnd = GetDesktopWindow(); HWND hwnd = GetDesktopWindow();
HDC hdc = GetWindowDC(hwnd); HDC hdc = GetWindowDC(hwnd);
HFONT hfntOld = SelectFont(hdc, (HFONT)font); HFONT hfntOld = SelectFont(hdc, (HFONT)font);
SIZE size;
TEXTMETRIC tm; TEXTMETRIC tm;
GetTextMetrics(hdc, &tm); GetTextMetrics(hdc, &tm);
gui.char_width = tm.tmAveCharWidth + tm.tmOverhang; // 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; gui.char_height = tm.tmHeight + p_linespace;

View File

@@ -767,6 +767,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1294,
/**/ /**/
1293, 1293,
/**/ /**/