Hi there,
Because of some reason, I am forced to use a couple of old DirectX 8 methods. I need to obtain somehow width of a given string in pixels. I'm using ID3DXFont interface, and create my font this way:
Code:
LOGFONT desc;
desc.lfHeight = _FontHeight;
desc.lfWidth = 0;
desc.lfEscapement = 0;
desc.lfOrientation = 0;
desc.lfWeight = FT_NORMAL;
desc.lfItalic = FALSE;
desc.lfUnderline = FALSE;
desc.lfStrikeOut = FALSE;
desc.lfCharSet = ANSI_CHARSET;
desc.lfOutPrecision = OUT_TT_PRECIS;
desc.lfClipPrecision = CLIP_DEFAULT_PRECIS;
desc.lfQuality = ANTIALIASED_QUALITY;
desc.lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH;
std::strcpy(desc.lfFaceName, "Courier New");
D3DXCreateFontIndirect(device, &desc, &font);
In DirectX 9 it's trivial to obtain HDC via GetDC method and then use GetTextExtentPoint32, but in D3D8 there is no such method.
Is there any way to obtain the text width? Or is there any way to obtain the DC? I know that I can create a GDI font, but such a solution is not good from my point of view (but if noone can come up with a better idea, I will do this).