microsoft / microsoft/terminal
Callback function passed to EnumFontFamiliesExW uses wrong signature
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
Example callback function used with EnumFontFamiliesExW:
int CALLBACK FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam);
But FONTENUMPROC as expected by EnumFontFamiliesExW is defined as follows (SDK 10.0.18362.0):
typedef int (CALLBACK* OLDFONTENUMPROCW)(CONST LOGFONTW *, CONST TEXTMETRICW *, DWORD, LPARAM);
In practice, the differing argument types are representation-compatible anyway, so it works fine, but it does require a cast on the function pointer. It was suggested in #871 to get this sorted out.
Affected files:
>git grep FONTENUMPROC
src/propsheet/misc.cpp: EnumFontFamiliesEx(hDC, &LogFont, (FONTENUMPROC)((ShouldAllowAllMonoTTFonts()) ? FontEnumForV2Console : FontEnum), (LPARAM)&fed, 0);
src/renderer/gdi/tool/main.cpp: EnumFontFamiliesExW( hDC, &lf, (FONTENUMPROC)EnumFontFamiliesExProc, 0, 0 );
src/tools/fontlist/main.cpp: EnumFontFamiliesExW(hdc.get(), &LogFont, (FONTENUMPROC)FontEnumForV2Console, (LPARAM)hdc.get(), 0);
BTW, src/renderer/gdi/tool/main.cpp is not included in any project in the solution, preventing it to be scanned by an IDE. Is that intentional?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the three files listed by git grep FONTENUMPROC, then compare FontEnumForV2Console, FontEnum, and EnumFontFamiliesExProc with the SDK FONTENUMPROC declaration. Done means the callbacks no longer require incompatible casts and the reason src/renderer/gdi/tool/main.cpp is absent from the solution is established or addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100