Skip to content

Properly round font size #1548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/Lib/ResourceHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ HFONT CreateFontSetting( const wchar_t *fontStr, int dpi )
weight=FW_BOLD, bItalic=true;
str=GetToken(str,token,_countof(token),L", \t");
int size=-_wtol(token);
return CreateFont(size*dpi/72,0,0,0,weight,bItalic?1:0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,name);
return CreateFont(MulDiv(size,dpi,72),0,0,0,weight,bItalic?1:0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,name);
}

static UINT WINAPI GetDpiForWindow(HWND hwnd)
Expand Down
2 changes: 1 addition & 1 deletion Src/Lib/SettingsUIHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2701,7 +2701,7 @@ LRESULT CTreeSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
else if (_wcsicmp(token,L"bold_italic")==0)
font.lfWeight=FW_BOLD, font.lfItalic=1;
str=GetToken(str,token,_countof(token),L", \t");
font.lfHeight=-(_wtol(token)*dpi+36)/72;
font.lfHeight=-MulDiv(_wtol(token),dpi,72);

CHOOSEFONT choose={sizeof(choose),m_hWnd,NULL,&font};
choose.Flags=CF_NOSCRIPTSEL;
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuDLL/StartButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ LRESULT CStartButton::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
m_Icon=(HICON)LoadImage(g_Instance,MAKEINTRESOURCE(IDI_APPICON),IMAGE_ICON,START_ICON_SIZE,START_ICON_SIZE,LR_DEFAULTCOLOR);
}
int dpi=CItemManager::GetDPI(false);
m_Font=CreateFont(10*dpi/72,0,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Tahoma");
m_Font=CreateFont(MulDiv(10,dpi,72),0,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Tahoma");
int val=1;
DwmSetWindowAttribute(m_hWnd,DWMWA_EXCLUDED_FROM_PEEK,&val,sizeof(val));
val=DWMFLIP3D_EXCLUDEABOVE;
Expand Down
2 changes: 1 addition & 1 deletion Src/Update/Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ LRESULT CUpdateDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
HDC hdc=::GetDC(NULL);
int dpi=GetDeviceCaps(hdc,LOGPIXELSY);
::ReleaseDC(NULL,hdc);
m_Font=CreateFont(-9*dpi/72,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH,L"Consolas");
m_Font=CreateFont(-MulDiv(9,dpi,72),0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH,L"Consolas");
if (m_Font)
GetDlgItem(IDC_EDITTEXT).SetFont(m_Font);
m_Tooltip.Create(TOOLTIPS_CLASS,m_hWnd,NULL,NULL,WS_POPUP|TTS_NOPREFIX);
Expand Down