以下是事实:我在Ubuntu上使用代码块.我已经安装了SDL和SDL_ttf并已成功包含和链接它们.我想将文本渲染到字体的屏幕FreeSerif.
这是问题:当程序到达行TTF_OpenFont("FreeSerif.ttf,20")时,它返回NULL,如果传递给TTF_RenderText_Solid函数,则会导致段错误.我已将字体文件添加到项目中,但仍然无效.
这是代码:
TTF_Init();
TTF_Font *font = TTF_OpenFont("FreeSerif.ttf",20); //This returns NULL
if(!font){printf("Unable to open font");exit(1);} //The program exits here
Run Code Online (Sandbox Code Playgroud)