1 const char *NAME = "xftlsfonts";
2 const char *VERSION = "1.0";
7 int main(int, char **) {
8 cout << NAME << " version " << VERSION << endl;
9 cout << "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl;
11 cout << "Openbox was built without support for Xft fonts. This utility must"
13 cout << "must be built with Xft support in order to function." << endl;
18 #include <X11/Xft/Xft.h>
29 int main(int argc, char **argv) {
31 for (int i = 1; i < argc; ++i)
32 if (string(argv[i]) == "-help" ||
33 string(argv[i]) == "--help" ||
34 string(argv[i]) == "-version" ||
35 string(argv[i]) == "--version") {
36 cout << NAME << " version " << VERSION << endl;
37 cout << "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl;
39 cout << "Usage: " << argv[0] << " [options]" << endl;
40 cout << " -style Show possible styles for each font" << endl;
41 cout << " -slant Show the slant for each font" << endl;
42 cout << " -weight Show the weight for each font" << endl;
43 cout << " -file Show which files contain each font" << endl;
48 Display *display = XOpenDisplay(NULL);
50 cout << "Failed to open connection to X display\n";
54 XftObjectSet *obj = XftObjectSetCreate();
56 cout << "Failed to create an XftObjectSet\n";
60 XftObjectSetAdd(obj, XFT_FAMILY);
63 for (int i = 1; i < argc; ++i) {
64 if (string(argv[i]) == "-style") XftObjectSetAdd(obj, XFT_STYLE);
65 else if (string(argv[i]) == "-file") XftObjectSetAdd(obj, XFT_FILE);
66 else if (string(argv[i]) == "-slant") XftObjectSetAdd(obj, XFT_SLANT);
67 else if (string(argv[i]) == "-weight") XftObjectSetAdd(obj, XFT_WEIGHT);
70 XftPattern *pat = XftPatternCreate();
72 cout << "Failed to create an XftPattern\n";
76 XftFontSet *set = XftListFontsPatternObjects(display, DefaultScreen(display),
79 cout << "Failed to find a matching XftFontSet\n";
86 for (int i = 0; i < set->nfont; ++i) {
87 for (int e = 0; e < set->fonts[i]->num; ++e) {
88 // if (string(set->fonts[i]->elts[e].object) != "family")
89 // continue; // i just want font family names
92 cout << " "; // indent after the first element
93 cout << set->fonts[i]->elts[e].object << ": ";
95 XftValueList *vallist = set->fonts[i]->elts[e].values;
103 XftValue val = vallist->value;
126 cout << "xx(" << val.u.m->xx << ") ";
127 cout << "xy(" << val.u.m->xy << ") ";
128 cout << "yx(" << val.u.m->yx << ") ";
129 cout << "yy(" << val.u.m->yy << ")";
132 } while ((vallist = vallist->next));
137 cout << endl << "Found " << set->nfont << " matches." << endl;
141 XCloseDisplay(display);