Page 1 of 1

Drawing TrueType text

Posted: April 7th, 2017, 1:01 pm
by LukaTheSerb
Hi everyone, I'm new here and I hope I don't make a mistake by asking something here, but whatever...

Recently I wanted to draw truetype text instead the bitmap one you use in your framework. I tried using LPD3DXFONT and DrawTextA() but it seems that no text appear on screen. Is it a problem that this framework directly writes on video buffer and DrawTextA() on sprite, or what? I'm doing this:

Code: Select all

void D3DGraphics::_DrawText(int x, int y, char* str, char* fontface, int size ,int r, int g, int b)
{
	LPD3DXFONT Font;
	RECT FontRect;
	D3DXCreateFontA(pDevice, size, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE, fontface, &Font);
	SetRect(&FontRect, x, y, 800, 600);
	Font->DrawTextA(NULL, str, 0, &FontRect, DT_LEFT, D3DCOLOR_XRGB(r, g, b));
	Font->Release();
}
Any help?

Re: Drawing TrueType text

Posted: April 8th, 2017, 3:39 am
by albinopapa
Should you really be creating and releasing fonts in the same function every frame? Not as if that is the problem. You need to upload your project for better help.