gpt4 book ai didi

fonts - 如何确定X11加载的字体名称?

转载 作者:行者123 更新时间:2023-12-03 22:47:01 27 4
gpt4 key购买 nike

如果我使用以下方法加载字体:

char *fName = (char *)"*-c-60-iso8859-1";
XFontStruct *font = XLoadQueryFont(disp, fName);

它可以是与通配符名称匹配的几种字体中的任何一种。
如何确定实际加载的全名?

[编辑] 更正通配符名称以匹配多个: -c--m-哪个都不匹配。 [结尾]

最佳答案

它是 XA_FONT字体的属性。

#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char* argv[])
{
Display* d = XOpenDisplay(0);
if (!d)
{
fprintf (stderr, "Oops, can't open display\n");
exit(EXIT_FAILURE);
}

while (*++argv)
{
XFontStruct* f = XLoadQueryFont(d, *argv);
unsigned long ret;
if (f == 0)
printf ("XLoadQueryFont failed for %s!\n", *argv);
else
{
if (!XGetFontProperty(f, XA_FONT, &ret))
printf ("XGetFontProperty(%s, XA_FONT) failed!\n", *argv);
else
printf ("Full name for %s is %s\n", *argv, XGetAtomName(d, (Atom)ret));
}
}
return 0;
}

运行:
$ ./prog r14 9x15bold foo
Full name for r14 is -Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-JISX0201.1976-0
Full name for 9x15bold is -Misc-Fixed-Bold-R-Normal--15-140-75-75-C-90-ISO8859-1
XLoadQueryFont failed for foo!

关于fonts - 如何确定X11加载的字体名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27765649/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com