Hi,
After creating a windows file browse dialog and choosing any of the files in browse dialog TTF crashes and is not able to open the font.
What’s more interesting, when I do the same but with folder browse dialog, it works as it should.
TTF_GetError() gives me an error, that cannot open that font.
I tried to run this function on main thread and different thread, and it’s the same.
void FileBrowser::OpenFileBrowser()
{
std::string filenameBuffer;
OPENFILENAMEA ofn;
convertedFilenames.erase();
filenameBuffer.resize(MAX_FILEPATH_BUFFER_SIZE);
ZeroMemory(&filenameBuffer[0], filenameBuffer.size());
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = Window::GetHWNDWindow();
ofn.lpstrFilter = "All Files\0*.*\0\0";// filterC;
ofn.lpstrFile = &filenameBuffer[0];
ofn.nMaxFile = MAX_FILEPATH_BUFFER_SIZE;
ofn.lpstrTitle = "Open";
ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
if (GetOpenFileNameA(&ofn) == FALSE)
convertedFilenames = "";
/* Font after choosing any of the files won't open, it will be NULL. When dialog is only opened
and canceled, font is opened properly. Only causes errors when file is chosen.
*/
TTF_Font* font = TTF_OpenFont(Strings::_FONT_PATH.c_str(), 14);
TTF_CloseFont(font);
filenameBuffer.erase();
}