Hi,
I'm designing a 2D game engine using DirectX 9.0c.
I am currently working on the graphics core.
Before using "DrawTextA", how would I get the size of TTF text width in pixels?
(I need to know it for horizontal positioning on the screen)
Thanks!
JeZ+Lee
Here is my source code:
//-------------------------------------------------------------------------------------------------------------------------------
void Visuals::DrawTextOntoScreenBuffer(const char *textToDisplay, LPD3DXFONT Font, int posX, int posY,
int XJustification, int textRed, int textGreen, int textBlue,
int outlineRed, int outlineGreen, int outlineBlue)
{
RECT rect;
// Horizonal positioning would go here...
//#define JustifyLeft 0
//#define JustifyCenter 1
//#define JustifyRight 2
//#define JustifyCenterOnPoint 3
for (int screenY = -2; screenY < 3; screenY++)
{
for (int screenX = -2; screenX < 3; screenX++)
{
SetRect( &rect, posX+screenX, posY+screenY, 0, 0 );
if (screenY != 0 && screenX != 0)
Font[0].DrawTextA( NULL, textToDisplay, -1, &rect, DT_NOCLIP, D3DCOLOR_RGBA(outlineRed, outlineGreen, outlineBlue, 255) );
}
}
SetRect( &rect, posX, posY, 0, 0 );
Font[0].DrawTextA( NULL, textToDisplay, -1, &rect, DT_NOCLIP, D3DCOLOR_RGBA(textRed, textGreen, textBlue, 255) );
}
//-------------------------------------------------------------------------------------------------------------------------------