Hi all,
I've been struggling with using AddFontResource(A) to add a font to my application session.
When I executet the code without breakpoints, the font doesn't show up, but when I add a breakpoint after the call to AddFontResourceA, it does work as expected.
I checked the return code in both working/ not working cases, always 1, which is as expected.
Also tried to call SendMessage like MSDN describes (HWND_BROADCAST, WM_FONTCHANGE), but without luck.
The only thing I can think of, is that the breakpoint makes the window loose focus and continuing 'refreshes' things.
But so far I havent been able to reproduce this (with sending WM_ACTIVATE for example).
Any thoughts on what might be happening here?
bool DX11FontRenderer::AddCurrFontToSystem()
{
if(!mCurrFont->IsLoaded())
{
std::string fullFileName = std::string(IO_FOLDER_FONTS) + mCurrFont->GetFilename().c_str();
int result = AddFontResourceA(fullFileName.c_str());
if(result == 0)
{
CLOG(ERROR, "DX11RENDERER") << error_loadfont.c_str() << mCurrFont->GetFilename();
return false;
}
CLOG(DEBUG, "DX11RENDERER") << debug_font_added.c_str() << mCurrFont->GetFontName();
CLOG(DEBUG, "DX11RENDERER") << "FONTS ADDED, RESULT: " << result;
mCurrFont->SetLoaded(true);
mAddedSystemFonts.push_back(fullFileName);
}
return true;
}