• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision28243 (tree)
Time2018-06-02 16:45:45
Authorstefankueng

Log Message

Get the default fonts via SystemParametersInfo(SPI_GETNONCLIENTMETRICS,..) instead of using the stock fonts:
the stock fonts don't scale on high dpi displays and therefore are way too small.

Change Summary

Incremental Difference

--- trunk/src/Utils/MiscUI/HyperLink.cpp (revision 28242)
+++ trunk/src/Utils/MiscUI/HyperLink.cpp (revision 28243)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2006, 2008, 2011-2012, 2014 - TortoiseSVN
3+// Copyright (C) 2003-2006, 2008, 2011-2012, 2014, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -77,19 +77,18 @@
7777 SetWindowText(m_strURL);
7878 }
7979
80+ LOGFONT lf;
8081 CFont* pFont = GetFont();
81- if (!pFont)
82+ if (pFont)
83+ pFont->GetObject(sizeof(lf), &lf);
84+ else
8285 {
83- HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
84- if (hFont == NULL)
85- hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
86- if (hFont)
87- pFont = CFont::FromHandle(hFont);
86+ NONCLIENTMETRICS metrics = { 0 };
87+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
88+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
89+ memcpy_s(&lf, sizeof(LOGFONT), &metrics.lfMessageFont, sizeof(LOGFONT));
8890 }
89- ASSERT(pFont->GetSafeHandle());
9091
91- LOGFONT lf;
92- pFont->GetLogFont(&lf);
9392 m_StdFont.CreateFontIndirect(&lf);
9493 lf.lfUnderline = (BYTE) TRUE;
9594 m_UnderlineFont.CreateFontIndirect(&lf);
--- trunk/src/Utils/MiscUI/HintCtrl.h (revision 28242)
+++ trunk/src/Utils/MiscUI/HintCtrl.h (revision 28243)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2011, 2013, 2015, 2017 - TortoiseSVN
3+// Copyright (C) 2011, 2013, 2015, 2017-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -28,8 +28,18 @@
2828 template <typename BaseType> class CHintCtrl : public BaseType
2929 {
3030 public:
31- CHintCtrl() : BaseType() {}
32- ~CHintCtrl() {}
31+ CHintCtrl() : BaseType(), m_uiFont(0)
32+ {
33+ NONCLIENTMETRICS metrics = { 0 };
34+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
35+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
36+ m_uiFont = CreateFontIndirect(&metrics.lfMessageFont);
37+ }
38+ virtual ~CHintCtrl()
39+ {
40+ if (m_uiFont)
41+ DeleteObject(m_uiFont);
42+ }
3343
3444 virtual ULONG GetGestureStatus(CPoint /*ptTouch*/) override
3545 {
@@ -96,7 +106,7 @@
96106 else
97107 memDC.FillSolidRect(rc, clrTextBk);
98108 rc.top += 10;
99- CGdiObject * oldfont = memDC.SelectStockObject(DEFAULT_GUI_FONT);
109+ CGdiObject * oldfont = memDC.SelectObject(CGdiObject::FromHandle(m_uiFont));
100110 memDC.DrawText(m_sText, rc, DT_CENTER | DT_VCENTER |
101111 DT_WORDBREAK | DT_NOPREFIX | DT_NOCLIP);
102112 memDC.SelectObject(oldfont);
@@ -117,6 +127,7 @@
117127
118128 private:
119129 CString m_sText;
130+ HFONT m_uiFont;
120131 };
121132
122133 BEGIN_TEMPLATE_MESSAGE_MAP(CHintCtrl, BaseType, BaseType)
--- trunk/src/Utils/MiscUI/LinkControl.cpp (revision 28242)
+++ trunk/src/Utils/MiscUI/LinkControl.cpp (revision 28243)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009, 2012-2016 - TortoiseSVN
3+// Copyright (C) 2009, 2012-2016, 2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -52,19 +52,18 @@
5252 }
5353
5454 // Create an updated font by adding an underline.
55+ LOGFONT lf;
5556 CFont* pFont = GetFont();
56- if (!pFont)
57+ if (pFont)
58+ pFont->GetObject(sizeof(lf), &lf);
59+ else
5760 {
58- HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
59- if (hFont == NULL)
60- hFont = (HFONT)GetStockObject(ANSI_VAR_FONT);
61- if (hFont)
62- pFont = CFont::FromHandle(hFont);
61+ NONCLIENTMETRICS metrics = { 0 };
62+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
63+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
64+ memcpy_s(&lf, sizeof(LOGFONT), &metrics.lfMessageFont, sizeof(LOGFONT));
6365 }
64- ASSERT(pFont->GetSafeHandle());
6566
66- LOGFONT lf;
67- pFont->GetObject(sizeof(lf), &lf);
6867 lf.lfWeight = FW_BOLD;
6968 m_NormalFont.CreateFontIndirect(&lf);
7069
--- trunk/src/SVN/SVNStatusListCtrl.cpp (revision 28242)
+++ trunk/src/SVN/SVNStatusListCtrl.cpp (revision 28243)
@@ -367,12 +367,19 @@
367367 , m_bAllowPeggedExternals(false)
368368 , m_pContextMenu(nullptr)
369369 , m_hShellMenu(0)
370+ , m_uiFont(0)
370371 {
371372 m_tooltipbuf[0] = 0;
373+ NONCLIENTMETRICS metrics = { 0 };
374+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
375+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
376+ m_uiFont = CreateFontIndirect(&metrics.lfMessageFont);
372377 }
373378
374379 CSVNStatusListCtrl::~CSVNStatusListCtrl()
375380 {
381+ if (m_uiFont)
382+ DeleteObject(m_uiFont);
376383 ClearStatusArray();
377384 }
378385
@@ -5426,7 +5433,7 @@
54265433 memDC.SetBkColor(clrTextBk);
54275434 memDC.BitBlt(rc.left, rc.top, rc.Width(), rc.Height(), pDC, rc.left, rc.top, SRCCOPY);
54285435 rc.top += 10;
5429- CGdiObject * oldfont = memDC.SelectStockObject(DEFAULT_GUI_FONT);
5436+ CGdiObject * oldfont = memDC.SelectObject(CGdiObject::FromHandle(m_uiFont));
54305437 memDC.DrawText(str, rc, DT_CENTER | DT_VCENTER |
54315438 DT_WORDBREAK | DT_NOPREFIX | DT_NOCLIP);
54325439 memDC.SelectObject(oldfont);
--- trunk/src/SVN/SVNStatusListCtrl.h (revision 28242)
+++ trunk/src/SVN/SVNStatusListCtrl.h (revision 28243)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2015, 2017 - TortoiseSVN
3+// Copyright (C) 2003-2015, 2017-2018 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -1136,6 +1136,8 @@
11361136 HMENU m_hShellMenu;
11371137 LPCONTEXTMENU m_pContextMenu;
11381138
1139+ HFONT m_uiFont;
1140+
11391141 friend class CSVNStatusListCtrlDropTarget;
11401142 };
11411143
--- trunk/src/TortoiseBlame/TortoiseBlame.cpp (revision 28242)
+++ trunk/src/TortoiseBlame/TortoiseBlame.cpp (revision 28243)
@@ -87,6 +87,7 @@
8787 , m_ttVisible(false)
8888 , m_font(0)
8989 , m_italicFont(0)
90+ , m_uiFont(0)
9091 , m_blameWidth(0)
9192 , m_revWidth(0)
9293 , m_dateWidth(0)
@@ -128,6 +129,11 @@
128129 m_selectedRevColor = GetSysColor(COLOR_HIGHLIGHT);
129130 m_selectedAuthorColor = InterColor(m_selectedRevColor, m_textHighLightColor, 35);
130131 SecureZeroMemory(&m_fr, sizeof(m_fr));
132+
133+ NONCLIENTMETRICS metrics = { 0 };
134+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
135+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
136+ m_uiFont = CreateFontIndirect(&metrics.lfMessageFont);
131137 }
132138
133139 TortoiseBlame::~TortoiseBlame()
@@ -136,6 +142,8 @@
136142 DeleteObject(m_font);
137143 if (m_italicFont)
138144 DeleteObject(m_italicFont);
145+ if (m_uiFont)
146+ DeleteObject(m_uiFont);
139147 }
140148
141149 std::wstring TortoiseBlame::GetAppDirectory()
@@ -1549,7 +1557,7 @@
15491557 return;
15501558
15511559 RECT rc;
1552- HFONT oldfont = (HFONT)::SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));
1560+ HFONT oldfont = (HFONT)::SelectObject(hDC, m_uiFont);
15531561 GetClientRect(wHeader, &rc);
15541562 ::SetBkColor(hDC, ::GetSysColor(COLOR_BTNFACE));
15551563
--- trunk/src/TortoiseBlame/TortoiseBlame.h (revision 28242)
+++ trunk/src/TortoiseBlame/TortoiseBlame.h (revision 28243)
@@ -150,6 +150,7 @@
150150 //std::vector<COLORREF> m_colors;
151151 HFONT m_font;
152152 HFONT m_italicFont;
153+ HFONT m_uiFont;
153154 LONG m_blameWidth;
154155 LONG m_revWidth;
155156 LONG m_dateWidth;
--- trunk/ext/TreePropSheet/PropPageFrame.cpp (revision 28242)
+++ trunk/ext/TreePropSheet/PropPageFrame.cpp (revision 28243)
@@ -40,13 +40,20 @@
4040 : m_bShowCaption(FALSE),
4141 m_nCaptionHeight(0),
4242 m_hCaptionIcon(NULL),
43- m_dwMsgFormat(DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE)
43+ m_dwMsgFormat(DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE),
44+ m_uiFont(0)
4445 {
46+ NONCLIENTMETRICS metrics = { 0 };
47+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
48+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
49+ m_uiFont = CreateFontIndirect(&metrics.lfMessageFont);
4550 }
4651
4752
4853 CPropPageFrame::~CPropPageFrame()
4954 {
55+ if (m_uiFont)
56+ DeleteObject(m_uiFont);
5057 }
5158
5259
@@ -148,13 +155,13 @@
148155
149156 void CPropPageFrame::DrawMsg(CDC *pDc, CRect rect, LPCTSTR /*lpszMsg*/, DWORD /*dwFormat*/)
150157 {
151- CFont *pPrevFont = dynamic_cast<CFont*>(pDc->SelectStockObject(DEFAULT_GUI_FONT));
152- int nPrevBkMode = pDc->SetBkMode(TRANSPARENT);
158+ auto hOldFont = pDc->SelectObject(m_uiFont);
159+ int nPrevBkMode = pDc->SetBkMode(TRANSPARENT);
153160
154161 pDc->DrawText(GetMsgText(), rect, GetMsgFormat());
155162
156163 pDc->SetBkMode(nPrevBkMode);
157- pDc->SelectObject(pPrevFont);
164+ pDc->SelectObject(hOldFont);
158165 }
159166
160167
--- trunk/ext/TreePropSheet/PropPageFrame.h (revision 28242)
+++ trunk/ext/TreePropSheet/PropPageFrame.h (revision 28243)
@@ -292,6 +292,8 @@
292292
293293 /** Style to use when drawing the message text m_strMsg. */
294294 DWORD m_dwMsgFormat;
295+
296+ HFONT m_uiFont;
295297 };
296298
297299
Show on old repository browser