FreeType FT_New_Memory_Face 崩溃

los*_*110 2 freetype

我已将“arial.ttf”文件(取自我的 /Windows/Fonts 文件夹)加载到内存中,但是将其传递给 FT_New_Memory_Face 时会崩溃(在 FT_Open_Face 中的某处)。我无法调试这个,任何关于我可能做错了什么的线索?

unsigned char *fontBuffer = LoadFile("arial.ttf");
zip_uint64_t fSize = GetFileSize("arial.ttf");
FT_Library  library;   /* handle to library     */
FT_Face     face; 
int error = FT_Init_FreeType( &library );
if( error != 0 )
    printf("FT_Init_FreeType failed");

error = FT_New_Memory_Face( library,
                            (FT_Byte*)fontBuffer,
                            fSize,                  
                            0,                      
                            &face );
Run Code Online (Sandbox Code Playgroud)

los*_*110 5

结果证明问题出在我的身上,特别是 LoadFile 方法从堆栈而不是堆返回内存。图书馆工作正常。谢谢!