-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of the Issue
Regardless of the desktop scaling setting, the font size obtained on Windows 7 is always wrong - the font appears smaller than expected.
In the dpiManagerV2.cpp source file, the font name and size are obtained through the function:
LOGFONT DPIManagerV2::getDefaultGUIFontForDpi(UINT dpi, FontType type)
{
int result = 0;
LOGFONT lf{};
NONCLIENTMETRICS ncm{};
ncm.cbSize = sizeof(NONCLIENTMETRICS);
if (_fnSystemParametersInfoForDpi != nullptr
&& (_fnSystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0, dpi) != FALSE))
{
result = 2;
}
else if (::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0) != FALSE)
{
result = 1;
}
if (result > 0)
{
switch (type)
{
case FontType::menu:
{
lf = ncm.lfMenuFont;
break;
}
case FontType::status:
{
lf = ncm.lfStatusFont;
break;
}
case FontType::caption:
{
lf = ncm.lfCaptionFont;
break;
}
case FontType::smcaption:
{
lf = ncm.lfSmCaptionFont;
break;
}
//case FontType::message:
default:
{
lf = ncm.lfMessageFont;
break;
}
}
}
else // should not happen, fallback
{
auto hf = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
::GetObject(hf, sizeof(LOGFONT), &lf);
}
if (result < 2)
{
lf.lfHeight = scaleFont(lf.lfHeight, dpi);
}
return lf;
}
On Windows 7, the variable result = 1;, which means the following block is always executed:
if (result < 2)
{
lf.lfHeight = scaleFont(lf.lfHeight, dpi);
}
Based on my testing, before this code is executed, the value of lf.lfHeight is already correct (it should be -11 on English systems, and -12 on CJK systems).
However, after the line lf.lfHeight = scaleFont(lf.lfHeight, dpi);,
lf.lfHeight becomes a positive value, which causes the font on the interface to appear smaller than it should.
I believe this line can be removed, or modified as follows:
if (lf.lfHeight > 0)
{
lf.lfHeight = scaleFont(lf.lfHeight, dpi);
}
P.S.: In my actual testing, I have never encountered a case where lf.lfHeight > 0.
Steps To Reproduce
- Run Notepad++ on Windows 7.
Current Behavior
The interface font appears smaller than expected.
Expected Behavior
The interface font size should match the setting in the Windows 7 Control Panel.
Debug Information
Notepad++ v8.8.5 (64-bit)
Build time: Aug 14 2025 - 00:32:39
Scintilla/Lexilla included: 5.5.7/5.4.5
Boost Regex included: 1_85
Path: C:\Program Files\Notepad++\notepad++.exe
Command Line:
Admin mode: OFF
Local Conf mode: OFF
Cloud Config: OFF
Periodic Backup: ON
Placeholders: OFF
Scintilla Rendering Mode: SC_TECHNOLOGY_DIRECTWRITE (1)
Multi-instance Mode: monoInst
asNotepad: OFF
File Status Auto-Detection: cdEnabledNew (for current file/tab only)
Dark Mode: ON
OS Name: Windows 11 Pro (64-bit)
OS Version: 24H2
OS Build: 26100.6725
Current ANSI codepage: 1252Anything else?
No response