title: Direct3D ID3DXFont->DrawText Crash on Windows XP
body: <p>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 <code>DrawText</code> will return 0 (meaning it failed), and the second time it tries will cause the program to crash.</p>
  
  <p>Are there some restrictions with imported fonts in Direct3D on Windows XP? Is there a way I can get some useful error code, since <code>DrawText</code> returning 0 isn't very helpful on its own.</p>
  
  <p>For reference, here's my font importing code:</p>
  
  <pre><code>if (AddFontResourceEx("ttfFiles/tf2Build.ttf", FR_PRIVATE, 0) == 0) {
      // Throw exception.
  }
  </code></pre>
  
  <p>And here's how I create the <code>ID3DXFont</code> object (which also returns without a problem):</p>
  
  <pre><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(),
      &amp;d3dFont );
  
  if ( FAILED( result ) ) {
      // Throw exception.
  }
  </code></pre>
  
  <p><strong>Edit:</strong> I managed to get it to occur under a debugger in XP, and here's the quite scary error that appears:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.AccessViolationException' occured in DirectFont.exe
    Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</p>
  </blockquote>
  
  <p>And here is the stack trace:</p>
  
  <blockquote>
    <p>usp10.dll!ClientData::GetOtlTable()  + 0x35 bytes<br>
    usp10.dll!otlResourceMgr::getOtlTable()  + 0x7a bytes<br>
    usp10.dll!SubstituteOtlChars()  + 0x1af bytes<br>
    usp10.dll!OtlShape()  + 0x3c5 bytes<br>
    D3DX9_43.dll!D3DXCore::CFont::DrawTextAW()  + 0x5aa bytes 
    D3DX9_43.dll!D3DXCore::CFont::DrawTextA()  + 0x26 bytes   </p>
  </blockquote>