Sign in to follow this  
jengerer

ID3DXFont Crashes with Custom Font

Recommended Posts

jengerer    127
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.

[code]if (AddFontResourceEx("ttfFiles/tf2Build.ttf", FR_PRIVATE, 0) == 0) {
// Throw exception.
}
[/code]
And here's how I create the D3DXFont object (which also returns without a problem).

[code]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.
}[/code]
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this