]>
Dogcows Code - chaz/openbox/blob - util/xftlsfonts.cc
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 cout
<< "Failed to open connection to X display\n";
42 XftObjectSet
*obj
= XftObjectSetCreate();
44 cout
<< "Failed to create an XftObjectSet\n";
48 XftObjectSetAdd(obj
, XFT_FAMILY
);
51 for (int i
= 1; i
< argc
; ++i
) {
52 if (string(argv
[i
]) == "-style") XftObjectSetAdd(obj
, XFT_STYLE
);
53 else if (string(argv
[i
]) == "-file") XftObjectSetAdd(obj
, XFT_FILE
);
54 else if (string(argv
[i
]) == "-slant") XftObjectSetAdd(obj
, XFT_SLANT
);
55 else if (string(argv
[i
]) == "-weight") XftObjectSetAdd(obj
, XFT_WEIGHT
);
58 XftPattern
*pat
= XftPatternCreate();
60 cout
<< "Failed to create an XftPattern\n";
64 XftFontSet
*set
= XftListFontsPatternObjects(display
, DefaultScreen(display
),
67 cout
<< "Failed to find a matching XftFontSet\n";
74 for (int i
= 0; i
< set
->nfont
; ++i
) {
75 for (int e
= 0; e
< set
->fonts
[i
]->num
; ++e
) {
76 // if (string(set->fonts[i]->elts[e].object) != "family")
77 // continue; // i just want font family names
80 cout
<< " "; // indent after the first element
81 cout
<< set
->fonts
[i
]->elts
[e
].object
<< ": ";
83 XftValueList
*vallist
= set
->fonts
[i
]->elts
[e
].values
;
91 XftValue val
= vallist
->value
;
114 cout
<< "xx(" << val
.u
.m
->xx
<< ") ";
115 cout
<< "xy(" << val
.u
.m
->xy
<< ") ";
116 cout
<< "yx(" << val
.u
.m
->yx
<< ") ";
117 cout
<< "yy(" << val
.u
.m
->yy
<< ")";
120 } while ((vallist
= vallist
->next
));
125 cout
<< endl
<< "Found " << set
->nfont
<< " matches." << endl
;
129 XCloseDisplay(display
);
This page took 0.038528 seconds and 4 git commands to generate.