Hi

I am using VS 2012 and making a app which displays several texts via GDI+ DrawText. When using ARIAL font, text looks okay, no problems.
But I wanted to use my own ttf fonts for the texts. So I added the ttf files to the resources and made an BINARY Object out of this ttf files.
When I use one font only all text are displayed ok. But when I use different fonts in the same WM_PAINT loop, the text looks completely garbage, strange letters are displayed.

Here is my code for displaying the text, it is called in my own method (DrawText) and is called for every text element, so local variables are destroyed.

Does the LoadResource/LockResource need a unlock or something???? I think it allocates some wrong memory when loading a second font..??

Code:
        Gdiplus::PrivateFontCollection fntcol;
	HINSTANCE hResInstance = (HINSTANCE)GetModuleHandle(NULL);
	HRSRC res = ::FindResource(hResInstance, MAKEINTRESOURCE(font.id), L"BINARY");
	if (res) {
		HGLOBAL mem = ::LoadResource(hResInstance, res);
		void *data = ::LockResource(mem);
		size_t len = ::SizeofResource(hResInstance, res);
		Gdiplus::Status nResults = fntcol.AddMemoryFont(data,len);
	}

	FontFamily fontFamily;
	int nNumFound=0;
	Gdiplus::Status nResults = fntcol.GetFamilies(1,&fontFamily, &nNumFound);
	Gdiplus::Font fnt(&fontFamily,(float)font.size,FontStyleRegular,UnitPixel);
	
	LinearGradientBrush brush(Rect(x,y, 1000, (int)fnt.GetHeight(&rgraphics)), col1, col2, LinearGradientModeVertical);
	rgraphics.DrawString(text, -1, &fnt, origin, &fmt, &brush);
Here are 3 example images, the first two are ok, the third one is not:

The first uses only one font resource (IDR_FNT_ROBOTO_COND_BOLD):
Name:  1._modjsa.png
Views: 2778
Size:  10.7 KB


The second uses a second font resource, but only that one (IDR_FNT_BEBASNEUE_REG):
Name:  2_gtw9st.png
Views: 5134
Size:  9.4 KB

And here the third example, where I use both fonts:
Name:  3_kpeo7m.png
Views: 3374
Size:  9.0 KB

As you can see, every font alone works fine, but when I use more than one, the output text is garbage.

thanks for any help.
regards
Erich