• Advertisement
Sign in to follow this  

ID3DXFont Crashes with Custom Font

This topic is 2440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


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(
isBolded ? FW_BOLD : FW_NORMAL,
&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.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement