]>
Dogcows Code - chaz/openbox/blob - util/xftlsfonts.cc
1 const char *NAME
= "xftlsfonts";
2 const char *VERSION
= "1.0";
6 #endif // HAVE_CONFIG_H
13 int main(int, char **) {
14 cout
<< NAME
<< " version " << VERSION
<< endl
;
15 cout
<< "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl
;
17 cout
<< "Openbox was built without support for Xft fonts. This utility must"
19 cout
<< "must be built with Xft support in order to function." << endl
;
24 #include <X11/Xft/Xft.h>
35 int main(int argc
, char **argv
) {
37 for (int i
= 1; i
< argc
; ++i
)
38 if (string(argv
[i
]) == "-help" ||
39 string(argv
[i
]) == "--help" ||
40 string(argv
[i
]) == "-version" ||
41 string(argv
[i
]) == "--version") {
42 cout
<< NAME
<< " version " << VERSION
<< endl
;
43 cout
<< "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl
;
45 cout
<< "Usage: " << argv
[0] << " [options]" << endl
;
46 cout
<< " -style Show possible styles for each font" << endl
;
47 cout
<< " -slant Show the slant for each font" << endl
;
48 cout
<< " -weight Show the weight for each font" << endl
;
49 cout
<< " -file Show which files contain each font" << endl
;
54 Display
*display
= XOpenDisplay(NULL
);
56 cout
<< "Failed to open connection to X display\n";
60 XftObjectSet
*obj
= XftObjectSetCreate();
62 cout
<< "Failed to create an XftObjectSet\n";
66 XftObjectSetAdd(obj
, XFT_FAMILY
);
69 for (int i
= 1; i
< argc
; ++i
) {
70 if (string(argv
[i
]) == "-style") XftObjectSetAdd(obj
, XFT_STYLE
);
71 else if (string(argv
[i
]) == "-file") XftObjectSetAdd(obj
, XFT_FILE
);
72 else if (string(argv
[i
]) == "-slant") XftObjectSetAdd(obj
, XFT_SLANT
);
73 else if (string(argv
[i
]) == "-weight") XftObjectSetAdd(obj
, XFT_WEIGHT
);
76 XftPattern
*pat
= XftPatternCreate();
78 cout
<< "Failed to create an XftPattern\n";
82 XftFontSet
*set
= XftListFontsPatternObjects(display
, DefaultScreen(display
),
85 cout
<< "Failed to find a matching XftFontSet\n";
92 for (int i
= 0; i
< set
->nfont
; ++i
) {
93 for (int e
= 0; e
< set
->fonts
[i
]->num
; ++e
) {
94 // if (string(set->fonts[i]->elts[e].object) != "family")
95 // continue; // i just want font family names
98 cout
<< " "; // indent after the first element
99 cout
<< set
->fonts
[i
]->elts
[e
].object
<< ": ";
101 XftValueList
*vallist
= set
->fonts
[i
]->elts
[e
].values
;
109 XftValue val
= vallist
->value
;
133 cout
<< "xx(" << val
.u
.m
->xx
<< ") ";
134 cout
<< "xy(" << val
.u
.m
->xy
<< ") ";
135 cout
<< "yx(" << val
.u
.m
->yx
<< ") ";
136 cout
<< "yy(" << val
.u
.m
->yy
<< ")";
140 } while ((vallist
= vallist
->next
));
145 cout
<< endl
<< "Found " << set
->nfont
<< " matches." << endl
;
149 XCloseDisplay(display
);
This page took 0.038854 seconds and 4 git commands to generate.