Try to use the GDI+ variables after initialisation of GDI+ engine. For example:
// PrivateFontCollection fontCollection; <-- MOVED
int main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
PrivateFontCollection fontCollection;
. . .
To use global variables:
PrivateFontCollection* fontCollection;
int main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
fontCollection = new PrivateFontCollection;
. . .