Drawing TrueType text

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
LukaTheSerb
Posts: 1
Joined: April 7th, 2017, 12:57 pm
Location: ex-Yugoslavia

Drawing TrueType text

Post by LukaTheSerb » April 7th, 2017, 1:01 pm

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?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Drawing TrueType text

Post by albinopapa » April 8th, 2017, 3:39 am

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply