Patch 8.2.4194
Problem:    MS-Windows: code for calculating font size is duplicated.
Solution:   Move the code to a function. (Ken Takata, closes #9603)
Files:      src/gui_w32.c


*** ../vim-8.2.4193/src/gui_w32.c       2022-01-23 12:31:53.757946551 +0000
--- src/gui_w32.c       2022-01-23 16:24:50.351892108 +0000
***************
*** 1511,1516 ****
--- 1511,1530 ----
  }
  
  /*
+  * Get the average character size of a font.
+  */
+     static void
+ GetAverageFontSize(HDC hdc, SIZE *size)
+ {
+     // GetTextMetrics() may not return the right value in tmAveCharWidth
+     // for some fonts.  Do our own average computation.
+     GetTextExtentPoint(hdc,
+           "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+           52, size);
+     size->cx = (size->cx / 26 + 1) / 2;
+ }
+ 
+ /*
   * Get the character size of a font.
   */
      static void
***************
*** 1523,1535 ****
      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;
  
      SelectFont(hdc, hfntOld);
--- 1537,1545 ----
      TEXTMETRIC tm;
  
      GetTextMetrics(hdc, &tm);
!     GetAverageFontSize(hdc, &size);
  
+     gui.char_width = size.cx + tm.tmOverhang;
      gui.char_height = tm.tmHeight + p_linespace;
  
      SelectFont(hdc, hfntOld);
***************
*** 7563,7579 ****
  
      hdc = GetDC(s_hwnd);
      SelectObject(hdc, hfontTools);
!     /*
!      * GetTextMetrics() doesn't return the right value in
!      * tmAveCharWidth, so we have to figure out the dialog base units
!      * ourselves.
!      */
!     GetTextExtentPoint(hdc,
!           "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
!           52, &size);
      ReleaseDC(s_hwnd, hdc);
  
!     s_dlgfntwidth = (WORD)((size.cx / 26 + 1) / 2);
      s_dlgfntheight = (WORD)size.cy;
  }
  
--- 7573,7582 ----
  
      hdc = GetDC(s_hwnd);
      SelectObject(hdc, hfontTools);
!     GetAverageFontSize(hdc, &size);
      ReleaseDC(s_hwnd, hdc);
  
!     s_dlgfntwidth = (WORD)size.cx;
      s_dlgfntheight = (WORD)size.cy;
  }
  
*** ../vim-8.2.4193/src/version.c       2022-01-23 14:17:24.631509344 +0000
--- src/version.c       2022-01-23 16:24:37.344157255 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4194,
  /**/

-- 
Permission is granted to read this message out aloud on Kings Cross Road,
London, under the condition that the orator is properly dressed.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220123162547.4E4971C44F7%40moolenaar.net.

Raspunde prin e-mail lui