summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2009-10-29 09:44:54 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2009-10-29 09:44:54 (GMT)
commit0f2aa87192cc95c6095ccce0e517004664c2061f (patch)
treecf86ea2bea4712ca34f89127f382c88f77629f5d /win
parentf960bd30e3d2ad3152235a100cb11d80fe971c4d (diff)
downloadtk-0f2aa87192cc95c6095ccce0e517004664c2061f.zip
tk-0f2aa87192cc95c6095ccce0e517004664c2061f.tar.gz
tk-0f2aa87192cc95c6095ccce0e517004664c2061f.tar.bz2
[Bug 1825353] Fix tiny fixed font on Russian Windows.
This patch reverts a previous attempt to fix tiny fonts on Russian Windows. It fixes the issue by requesting a suitable fixed font instead of decoding the system stock font.
Diffstat (limited to 'win')
-rw-r--r--win/tkWinFont.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index a1ef63a..79df98c 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.46 2009/01/28 20:47:49 nijtmans Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.47 2009/10/29 09:44:55 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -449,8 +449,24 @@ TkWinSetupSystemFonts(
&iconMetrics.lfFont);
}
- hFont = (HFONT) GetStockObject(ANSI_FIXED_FONT);
- CreateNamedSystemFont(interp, tkwin, "TkFixedFont", hFont);
+ /*
+ * Identify an available fixed font. Equivalent to ANSI_FIXED_FONT but
+ * more reliable on Russian Windows.
+ */
+
+ {
+ LOGFONTA lfFixed = {
+ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, ""
+ };
+ long pointSize, dpi;
+ HDC hdc = GetDC(NULL);
+ dpi = GetDeviceCaps(hdc, LOGPIXELSY);
+ pointSize = -MulDiv(ncMetrics.lfMessageFont.lfHeight, 72, dpi);
+ lfFixed.lfHeight = -MulDiv(pointSize+1, dpi, 72);
+ ReleaseDC(NULL, hdc);
+ CreateNamedSystemLogFont(interp, tkwin, "TkFixedFont", &lfFixed);
+ }
/*
* Setup the remaining standard Tk font names as named fonts.
@@ -1586,20 +1602,7 @@ InitFont(
fontPtr->font.fid = (Font) fontPtr;
fontPtr->hwnd = hwnd;
- fontPtr->pixelSize = tm.tmHeight;
-
- /*
- * The font pixelSize should be the tmHeight - tmInternalLeading
- * but this causes fonts to appear too small on for instance
- * Russian systems where there is internal leading in use.
- * This hack appears to sort things out.
- * NB: the logic on this flag is reversed - this means if the
- * font is not fixed then subtract the leading value.
- */
-
- if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH) {
- fontPtr->pixelSize -= tm.tmInternalLeading;
- }
+ fontPtr->pixelSize = tm.tmHeight - tm.tmInternalLeading;
faPtr = &fontPtr->font.fa;
faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString));