title: Freetype2 failing under WoW64
body: <p>I built a tff to D3D texture function using freetype2(2.3.9) to generate grayscale maps from the fonts. it works great under native win32, however, on WoW64 it just explodes (well, <code>FT_Done</code> and <code>FT_Load_Glyph</code> do). from some debugging, it seems to be a problem with <code>HeapFree</code> as called by <code>free</code> from <code>FT_Free</code>. </p>
  
  <p>I know it should work, as games like WCIII, which to the best of my knowledge use freetype2, run fine, this is my code, stripped of the D3D code(which causes no problems on its own):</p>
  
  <pre><code>    FT_Face pFace = NULL;
      FT_Error nError = 0;
      FT_Byte* pFont = static_cast&lt;FT_Byte*&gt;(ARCHIVE_LoadFile(pBuffer,&amp;nSize));
      if((nError = FT_New_Memory_Face(pLibrary,pFont,nSize,0,&amp;pFace)) == 0)
      {
          FT_Set_Char_Size(pFace,nSize &lt;&lt; 6,nSize &lt;&lt; 6,96,96);
          for(unsigned char c = 0; c &lt; 95; c++)
          {
              if(!FT_Load_Glyph(pFace,FT_Get_Char_Index(pFace,c + 32),FT_LOAD_RENDER))
              {
                  FT_Glyph pGlyph;
                  if(!FT_Get_Glyph(pFace-&gt;glyph,&amp;pGlyph))
                  {
                      LOG("GET: %c",c + 32);
                      FT_Glyph_To_Bitmap(&amp;pGlyph,FT_RENDER_MODE_NORMAL,0,1);
                      FT_BitmapGlyph pGlyphMap = reinterpret_cast&lt;FT_BitmapGlyph&gt;(pGlyph);
                      FT_Bitmap* pBitmap = &amp;pGlyphMap-&gt;bitmap;
                      const size_t nWidth = pBitmap-&gt;width;
                      const size_t nHeight = pBitmap-&gt;rows;
                      //add to texture atlas
                  }
              }
          }
      }
      else
      {
          FT_Done_Face(pFace);
          delete pFont;   
          return FALSE;
      }
  
      FT_Done_Face(pFace);
      delete pFont;
      return TRUE;
  }
  </code></pre>
  
  <p><em><code>ARCHIVE_LoadFile</code> returns blocks allocated with <code>new</code>.</em></p>
  
  <p>As a secondary question, I would like to render a font using pixel sizes, I came across <code>FT_Set_Pixel_Sizes</code>, but I'm unsure as to whether this stretches the font to fit the size, or bounds it to a size. what I would like to do is render all the glyphs at say 24px (MS Word size here), then turn it into a signed distance field in a 32px area.</p>
  
  <p><strong>Update</strong></p>
  
  <p>After much fiddling, I got a test app to work, which leads me to think the problems are arising from threading, as my code is running in a secondary thread. I have compiled freetype into a static lib using the multithread DLL, my app uses the multithreaded libs. gonna see if i can set up a multithreaded test.</p>
  
  <p>Also updated to 2.4.4, to see if the problem was a known but fixed bug, didn't help however.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>After some more fiddling, it turns out I wasn't using the correct lib for 2.4.4 -.- after fixing that, the test app works 100%, but the main app still crashes when <code>FT_Done_Face</code> is called, still seems to be a crash in the memory heap management of windows. is it possible that there is a bug in freetype2 that makes it blow up under user threads? </p>