小编bis*_*uit的帖子

TTF_OpenFont()返回NULL

以下是事实:我在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)

macos ubuntu null qt sdl-ttf

5
推荐指数
1
解决办法
5265
查看次数

标签 统计

macos ×1

null ×1

qt ×1

sdl-ttf ×1

ubuntu ×1