【发布时间】:2019-03-08 17:30:33
【问题描述】:
您好,我是 X11 的新手,我正在尝试使用 XLoadFont 从目录加载字体,然后使用 XDrawText 打印一些文本,但由于某种原因,我无法加载我加载的字体(.ttf 格式)字体:
static void setFont(
Object *_this,
const char *path)
{
mc_textPr *this = _this;
Display *display = getDisplay();
Font tmp = XLoadFont(display, path);
if (!tmp) {
raise("Invalid path to font\n");
return;
}
unloadFont(this->text.font, display);
this->text.font = tmp;
}
在你之前,告诉我X11很难,应该用别的东西来做一个需要使用X11的学校项目。
这个资源我也知道
http://xopendisplay.hilltopia.ca/2009/Feb/Xlib-tutorial-part-4----Text.html
但我不知道为什么它会发疯。
这是实际的错误:
X Error of failed request: BadName (named color or font does not exist)
Major opcode of failed request: 45 (X_OpenFont)
Serial number of failed request: 17
Current serial number in output stream: 27
【问题讨论】: