【问题标题】:FreeType FT_New_Memory_Face crashesFreeType FT_New_Memory_Face 崩溃
【发布时间】:2011-09-06 07:14:17
【问题描述】:

我已将“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 );

【问题讨论】:

    标签: freetype


    【解决方案1】:

    原来问题出在我这边,特别是 LoadFile 方法是从堆栈而不是堆返回内存。图书馆工作正常。谢谢!

    【讨论】:

    • 嗨,几年后,你能提供LoadFile吗?我有同样的问题。我认为我的加载程序是错误的。
    【解决方案2】:

    我搜索了 1 天的答案。问题出在注释部分。 https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_New_Memory_Face 在调用 FT_Done_Face 之前,您不得释放内存。 FreeType 不复制缓冲区并使用您发送到 FT_New_Memory_Face 的指针

    【讨论】:

    • 我刚刚遇到了同样的问题。感谢发帖!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 1970-01-01
    • 2011-11-22
    • 2021-05-14
    • 1970-01-01
    • 2016-11-09
    相关资源
    最近更新 更多