3 #include <X11/Xft/Xft.h>
10 const char *NAME = "xftlsfonts";
11 const char *VERSION = "1.0";
17 int main(int argc, char **argv) {
19 for (int i = 1; i < argc; ++i)
20 if (string(argv[i]) == "-help" ||
21 string(argv[i]) == "--help" ||
22 string(argv[i]) == "-version" ||
23 string(argv[i]) == "--version") {
24 cout << NAME << " version " << VERSION << endl;
25 cout << "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl;
27 cout << "Usage: " << argv[0] << " [options]" << endl;
28 cout << " -style Show possible styles for each font" << endl;
29 cout << " -slant Show the slant for each font" << endl;
30 cout << " -weight Show the weight for each font" << endl;
31 cout << " -file Show which files contain each font" << endl;
36 Display *display = XOpenDisplay(NULL);
38 XftObjectSet *obj = XftObjectSetCreate();
40 cout << "Failed to create an XftObjectSet\n";
44 XftObjectSetAdd(obj, XFT_FAMILY);
47 for (int i = 1; i < argc; ++i) {
48 if (string(argv[i]) == "-style") XftObjectSetAdd(obj, XFT_STYLE);
49 else if (string(argv[i]) == "-file") XftObjectSetAdd(obj, XFT_FILE);
50 else if (string(argv[i]) == "-slant") XftObjectSetAdd(obj, XFT_SLANT);
51 else if (string(argv[i]) == "-weight") XftObjectSetAdd(obj, XFT_WEIGHT);
54 XftPattern *pat = XftPatternCreate();
56 cout << "Failed to create an XftPattern\n";
60 XftFontSet *set = XftListFontsPatternObjects(display, DefaultScreen(display),
63 cout << "Failed to find a matching XftFontSet\n";
70 for (int i = 0; i < set->nfont; ++i) {
71 for (int e = 0; e < set->fonts[i]->num; ++e) {
72 // if (string(set->fonts[i]->elts[e].object) != "family")
73 // continue; // i just want font family names
76 cout << " "; // indent after the first element
77 cout << set->fonts[i]->elts[e].object << ": ";
79 XftValueList *vallist = set->fonts[i]->elts[e].values;
87 XftValue val = vallist->value;
110 cout << "xx(" << val.u.m->xx << ") ";
111 cout << "xy(" << val.u.m->xy << ") ";
112 cout << "yx(" << val.u.m->yx << ") ";
113 cout << "yy(" << val.u.m->yy << ")";
116 } while ((vallist = vallist->next));
121 cout << endl << "Found " << set->nfont << " matches." << endl;
125 XCloseDisplay(display);