ID3DXFont Crashes with Custom Font

Started by
-1 comments, last by jengerer 12 years, 9 months ago
Hello,

I'm trying to load a font from a file and then use it in Direct3D, and it works perfectly on my Windows 7 machine, but if I try it on an XP SP2 machine, the first call to DrawText will return 0 (meaning it failed), and the second will cause the program to crash. Does anyone know of a reason why this would be happening? I've tried it with stock fonts like Arial, and they load and draw fine, but when I try to load this font, it fails.

Are there some restrictions with imported fonts in Direct3D on Windows XP? Is there a way I can get some useful error code, since DrawText returning 0 isn't very helpful on its own.

For reference, here's my font importing code.

if (AddFontResourceEx("ttfFiles/tf2Build.ttf", FR_PRIVATE, 0) == 0) {
// Throw exception.
}

And here's how I create the D3DXFont object (which also returns without a problem).

HRESULT result = D3DXCreateFont(
d3dDevice_,
height,
0,
isBolded ? FW_BOLD : FW_NORMAL,
0,
false,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_DONTCARE,
name.c_str(),
&d3dFont );

if ( FAILED( result ) ) {
// Throw exception.
}

I haven't run the program through a debugger yet, because I need SP3 in order to install VC++ 2010, but I'm trying to get VC++ 2008 on there now and make a sample program. Just thought I'd post here in case anyone has any insight on this issue. I tried it on an XP SP3 machine, and it seems to work, but I really would like to get it to work on both service packs.

Thanks,
Jengerer

This topic is closed to new replies.

Advertisement