diff options
author | patthoyts <patthoyts@noemail.net> | 2009-10-29 09:44:53 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@noemail.net> | 2009-10-29 09:44:53 (GMT) |
commit | 298f3ef76831ad1b5ce6ade3c2c788ac69cb07ac (patch) | |
tree | cf86ea2bea4712ca34f89127f382c88f77629f5d /win | |
parent | 25df3961bce4ce60d460e7b0b4b05f001efff127 (diff) | |
download | tk-298f3ef76831ad1b5ce6ade3c2c788ac69cb07ac.zip tk-298f3ef76831ad1b5ce6ade3c2c788ac69cb07ac.tar.gz tk-298f3ef76831ad1b5ce6ade3c2c788ac69cb07ac.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.
FossilOrigin-Name: 9a4fb5720188c02db4159b317726a06730a9f2db
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinFont.c | 37 |
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)); |