我正在尝试使用 FreeType 库编写一个简单的脚本。尽管我使用正确,但在执行 FT_Set_Pixel_Sizes 方法期间会发生段错误。任何帮助都会很棒。这是完整的代码:
#include <ft2build.h>
#include FT_FREETYPE_H
main() {
FT_Library library;
FT_Face face;
FT_GlyphSlot slot;
FT_UInt glyph_index = 30;
char* font_file = "/usr/share/fonts/truetype/freefont/FreeMono.ttf";
// Render font
FT_New_Face(library, font_file, 0, &face);
FT_Set_Pixel_Sizes(face, 0, 16); /* THIS LINE IS CAUSING THE SEGFAULT */
slot = face->glyph;
FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
}