linux, C++, xft : how to use it?

后端 未结 2 1301
盖世英雄少女心
盖世英雄少女心 2021-01-03 01:59

I try to use Xft, the tutorial, well let them calling that a tutorial... looks like it was written in a north korean camp... I also found this one. So let me try to do a ste

2条回答
  •  长情又很酷
    2021-01-03 02:52

    You should not pass an empty string to XftFontOpenName and expect to match a font. Xft provides support for core fonts and the structure nested within XftFont is a union of XFontStruct and XftFontStruct. X11 fills in the default font in the XFontStruct when creating new instances, so in the case of empty string you are likely getting the default core font.

    In the simplest approach, one can hard code a font name like this:

    const char *font_name = "Arial-20";
    XftFont *font = XftFontOpenName (display, DefaultScreen(display), font_name);
    

    Or you could use XftFontMatch and check the "results" before passing the pattern to XftFontOpenPattern. See http://keithp.com/~keithp/talks/xtc2001/paper/xft.html#sec-editing

    Note that XCloseDisplay is missing.

提交回复
热议问题