mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Experimental: use SHGetKnownFolderPath to get font path on Windows.
This commit is contained in:
@@ -898,11 +898,28 @@ void platform_get_exe_path(utf8 *outPath)
|
|||||||
WideCharToMultiByte(CP_UTF8, 0, exePath, countof(exePath), outPath, MAX_PATH, NULL, NULL);
|
WideCharToMultiByte(CP_UTF8, 0, exePath, countof(exePath), outPath, MAX_PATH, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer)
|
bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer)
|
||||||
{
|
{
|
||||||
strcpy(buffer, "C:\\Windows\\Fonts\\");
|
wchar_t *fontFolder;
|
||||||
strcat(buffer, font->filename);
|
if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_Fonts, 0, NULL, &fontFolder)))
|
||||||
return true;
|
{
|
||||||
|
// Convert wchar to utf8, then copy the font folder path to the buffer.
|
||||||
|
utf8 *outPathTemp = widechar_to_utf8(fontFolder);
|
||||||
|
strcpy(buffer, outPathTemp);
|
||||||
|
free(outPathTemp);
|
||||||
|
|
||||||
|
CoTaskMemFree(fontFolder);
|
||||||
|
|
||||||
|
// Append the requested font's file name.
|
||||||
|
const char separator[2] = { platform_get_path_separator(), 0 };
|
||||||
|
strcat(buffer, separator);
|
||||||
|
strcat(buffer, font->filename);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user