[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

fix for cleartype in MFC UIs

From: z <zeromus_at_zeromus.org>
Date: Sun, 17 Nov 2013 17:06:24 -0600

I am very offended by seeing cleartype when I have tried as best I can to
disable it in my operating system. It crops up in several places in
TortoiseSVN. I have studied why this is happening, and believe that I have
a clean solution for it. I've attached a patch for TortoiseMerge, which is
likely appropriate for the other programs.

The patch activates an MFC feature called "UseSystemFont" which sounds like
a responsible thing to do, doesn't it? But MFC has other opinions. At
least, it gives us this hook to disable it.

I don't think it should be debateable that MFC's default behaviour is
flagrantly disrespectful. But if we need to debate it, I'm game. For
reference, I am pasting the relevant code from afxglobals.cpp which is also
readily findable on the web:

    // Check if we should use system font
    lstrcpy(lf.lfFaceName, info.lfMenuFont.lfFaceName);

    BOOL fUseSystemFont = m_bUseSystemFont || (info.lfMenuFont.lfCharSet >
SYMBOL_CHARSET);
    if (!fUseSystemFont)
    {
        // Check for "Segoe UI" or "Tahoma" font existance:
        if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamilyProcFonts,
(LPARAM)(LPCTSTR) AFX_FONT_NAME_OFFICE_2007) == 0)
        {
            // Found! Use MS Office 2007 font!
            lstrcpy(lf.lfFaceName, AFX_FONT_NAME_OFFICE_2007);
            lf.lfQuality = 5 /*CLEARTYPE_QUALITY*/;
        }
        else if (::EnumFontFamilies(dc.GetSafeHdc(), NULL,
FontFamilyProcFonts, (LPARAM)(LPCTSTR) AFX_FONT_NAME_OFFICE) == 0)
        {
            // Found! Use MS Office font!
            lstrcpy(lf.lfFaceName, AFX_FONT_NAME_OFFICE);
        }
        else
        {
            // Not found. Use default font:
            lstrcpy(lf.lfFaceName, AFX_FONT_NAME_DEFAULT);
        }
    }

Index: TortoiseMerge.cpp
===================================================================
--- TortoiseMerge.cpp (revision 24957)
+++ TortoiseMerge.cpp (working copy)
@@ -183,6 +183,13 @@
     // visual styles. Otherwise, any window creation will fail.
     InitCommonControls();

+ // MFC is disrespectful of user settings and uses a segoe font
with cleartype enabled regardless of the user preferences for cleartype.
+ // for more information :
http://connect.microsoft.com/VisualStudio/feedback/details/780747
+ // By setting the following flag, we can tell MFC to be respectful
+ GetGlobalData()->m_bUseSystemFont = TRUE;
+ // Additionally, this must be called to re-select the font after
setting the flag
+ GetGlobalData()->UpdateFonts();
+

CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
     CMFCButton::EnableWindowsTheming();
     EnableTaskbarInteraction(FALSE);

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=3068648

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_tortoisesvn.tigris.org].

Received on 2013-11-18 00:07:15 CET

This is an archived mail posted to the TortoiseSVN Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.