Skip to content

Commit

Permalink
fix GetUserGuiFont() (fixes #3779)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Oct 23, 2023
1 parent aa75718 commit 7584ae9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Favorites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,11 @@ HFONT GetTreeFont() {
int fntSize = GetSizeOfDefaultGuiFont();
int fntSizeUser = gGlobalPrefs->treeFontSize;
int fntWeightOffsetUser = gGlobalPrefs->treeFontWeightOffset;
char* fntNameUser_utf8 = gGlobalPrefs->treeFontName;
char* fntNameUser = gGlobalPrefs->treeFontName;
if (fntSizeUser > 5) {
fntSize = fntSizeUser;
}
gTreeFont = GetUserGuiFont(fntSize, fntWeightOffsetUser, fntNameUser_utf8);
gTreeFont = GetUserGuiFont(fntSize, fntWeightOffsetUser, fntNameUser);
CrashIf(!gTreeFont);
return gTreeFont;
}
Expand Down
7 changes: 1 addition & 6 deletions src/utils/WinUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,10 +1390,9 @@ HFONT GetUserGuiFont(int size, int weightOffset, char* fontName) {
SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
ncm.lfMessageFont.lfHeight = -size;
if (fontName && !str::EqI(fontName, "automatic")) {
TempWstr fontNameW = ToWstrTemp(fontName);
WCHAR* dest = ncm.lfMessageFont.lfFaceName;
int cchDestBufSize = dimof(ncm.lfMessageFont.lfFaceName);
StrCatBuffW(dest, fontNameW, cchDestBufSize);
str::BufSet(dest, cchDestBufSize, fontName);
}
ncm.lfMessageFont.lfWeight += weightOffset;
HFONT fnt = CreateFontIndirectW(&ncm.lfMessageFont);
Expand Down Expand Up @@ -2911,7 +2910,3 @@ void AddPathToRecentDocs(const char* path) {
SHAddToRecentDocs(SHARD_PATH, pathW);
}

int GetGdiObjectsCount() {
DWORD n = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
return (int)n;
}
10 changes: 0 additions & 10 deletions src/utils/WinUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,3 @@ void TbGetRect(HWND hwnd, int buttonId, RECT* rc);

void TreeViewExpandRecursively(HWND hTree, HTREEITEM hItem, uint flag, bool subtree);
void AddPathToRecentDocs(const char*);

int GetGdiObjectsCount();

struct CheckGdiLeaks {
int initialCount = GetGdiObjectsCount();
~CheckGdiLeaks() {
int currCount = GetGdiObjectsCount();
CrashIf(currCount > initialCount);
}
};

0 comments on commit 7584ae9

Please sign in to comment.