]>
Dogcows Code - chaz/openbox/blob - util/xftlsfonts.cc
1 const char *NAME
= "xftlsfonts";
2 const char *VERSION
= "1.0";
6 #endif // HAVE_CONFIG_H
11 int main(int, char **) {
12 cout
<< NAME
<< " version " << VERSION
<< endl
;
13 cout
<< "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl
;
15 cout
<< "Openbox was built without support for Xft fonts. This utility must"
17 cout
<< "must be built with Xft support in order to function." << endl
;
22 #include <X11/Xft/Xft.h>
33 int main(int argc
, char **argv
) {
35 for (int i
= 1; i
< argc
; ++i
)
36 if (string(argv
[i
]) == "-help" ||
37 string(argv
[i
]) == "--help" ||
38 string(argv
[i
]) == "-version" ||
39 string(argv
[i
]) == "--version") {
40 cout
<< NAME
<< " version " << VERSION
<< endl
;
41 cout
<< "Copyright (c) 2002, Ben Jansens <ben@orodu.net>" << endl
;
43 cout
<< "Usage: " << argv
[0] << " [options]" << endl
;
44 cout
<< " -style Show possible styles for each font" << endl
;
45 cout
<< " -slant Show the slant for each font" << endl
;
46 cout
<< " -weight Show the weight for each font" << endl
;
47 cout
<< " -file Show which files contain each font" << endl
;
52 Display
*display
= XOpenDisplay(NULL
);
54 cout
<< "Failed to open connection to X display\n";
58 XftObjectSet
*obj
= XftObjectSetCreate();
60 cout
<< "Failed to create an XftObjectSet\n";
64 XftObjectSetAdd(obj
, XFT_FAMILY
);
67 for (int i
= 1; i
< argc
; ++i
) {
68 if (string(argv
[i
]) == "-style") XftObjectSetAdd(obj
, XFT_STYLE
);
69 else if (string(argv
[i
]) == "-file") XftObjectSetAdd(obj
, XFT_FILE
);
70 else if (string(argv
[i
]) == "-slant") XftObjectSetAdd(obj
, XFT_SLANT
);
71 else if (string(argv
[i
]) == "-weight") XftObjectSetAdd(obj
, XFT_WEIGHT
);
74 XftPattern
*pat
= XftPatternCreate();
76 cout
<< "Failed to create an XftPattern\n";
80 XftFontSet
*set
= XftListFontsPatternObjects(display
, DefaultScreen(display
),
83 cout
<< "Failed to find a matching XftFontSet\n";
90 for (int i
= 0; i
< set
->nfont
; ++i
) {
91 for (int e
= 0; e
< set
->fonts
[i
]->num
; ++e
) {
92 // if (string(set->fonts[i]->elts[e].object) != "family")
93 // continue; // i just want font family names
96 cout
<< " "; // indent after the first element
97 cout
<< set
->fonts
[i
]->elts
[e
].object
<< ": ";
99 XftValueList
*vallist
= set
->fonts
[i
]->elts
[e
].values
;
107 XftValue val
= vallist
->value
;
130 cout
<< "xx(" << val
.u
.m
->xx
<< ") ";
131 cout
<< "xy(" << val
.u
.m
->xy
<< ") ";
132 cout
<< "yx(" << val
.u
.m
->yx
<< ") ";
133 cout
<< "yy(" << val
.u
.m
->yy
<< ")";
136 } while ((vallist
= vallist
->next
));
141 cout
<< endl
<< "Found " << set
->nfont
<< " matches." << endl
;
145 XCloseDisplay(display
);
This page took 0.044728 seconds and 4 git commands to generate.