diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-07 22:52:50 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-07 22:52:50 +0200 |
commit | 93d77b2cbec08518ee426d0c44c50cf505732443 (patch) | |
tree | bcd7895a1039df6070feeb7da2561fa71a9e00dd /src | |
parent | fda9784dc9596e1e36f840bbf1935a4c4b502bd9 (diff) |
patch 8.1.1294: MS-Windows: Some fonts return wrong average char widthv8.1.1294
Problem: MS-Windows: Some fonts return wrong average char width.
Solution: Compute the average ourselves. (Ken Takata, closes #4356)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui_w32.c | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/gui_w32.c b/src/gui_w32.c index 3914733d78..7bea58e97c 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -1455,10 +1455,16 @@ GetFontSize(GuiFont font) HWND hwnd = GetDesktopWindow(); HDC hdc = GetWindowDC(hwnd); HFONT hfntOld = SelectFont(hdc, (HFONT)font); + SIZE size; TEXTMETRIC 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; diff --git a/src/version.c b/src/version.c index 21292fe26b..06a7a5f687 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1294, +/**/ 1293, /**/ 1292, |