From 0f2aa87192cc95c6095ccce0e517004664c2061f Mon Sep 17 00:00:00 2001 From: patthoyts Date: Thu, 29 Oct 2009 09:44:54 +0000 Subject: [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. --- ChangeLog | 7 +++++++ win/tkWinFont.c | 37 ++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ada61b..7655b57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-10-29 Pat Thoyts + + * win/tkWinFont.c: [Bug 1825353]: 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. + 2009-10-26 Don Porter * unix/Makefile.in: Remove $(PACKAGE).* and prototype from the 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)); -- cgit v0.12