diff options
author | Don Stewart <dons@cse.unsw.edu.au> | 2007-05-28 06:04:02 +0200 |
---|---|---|
committer | Don Stewart <dons@cse.unsw.edu.au> | 2007-05-28 06:04:02 +0200 |
commit | 232d45a1d52b3b9efefaf03d0c6a25a80b043ded (patch) | |
tree | 72bd1d4ab5ba64c14dcb0aad804c95710b7faa5b /util | |
parent | 5d96f06e3bc9d42a34fbca1d07791a7f427192a3 (diff) | |
download | xmonad-232d45a1d52b3b9efefaf03d0c6a25a80b043ded.tar.gz xmonad-232d45a1d52b3b9efefaf03d0c6a25a80b043ded.tar.xz xmonad-232d45a1d52b3b9efefaf03d0c6a25a80b043ded.zip |
move gapcalc.c
darcs-hash:20070528040402-9c5c1-972fe2622e36e57864a0af8734e9edacb27043d0.gz
Diffstat (limited to 'util')
-rw-r--r-- | util/gapcalc.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/util/gapcalc.c b/util/gapcalc.c deleted file mode 100644 index 4a4c3db..0000000 --- a/util/gapcalc.c +++ /dev/null @@ -1,70 +0,0 @@ -/* gapcalc - calculate height of given font - * Copyright (C) 2007 by Robert Manea <rob.manea@gmail.com> - * - * Compile with: cc -lX11 -o gapcalc gapcalc.c - */ - -#include<stdio.h> -#include<stdlib.h> -#include<stdarg.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -void -eprint(const char *errstr, ...) { - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - - -int -main(int argc, char *argv[]) { - Display *dpy; - XFontStruct *xfont; - XFontSet set; - char *def, **missing; - char *fontstr; - int i, n, ascent, descent; - - if(argc < 2) - eprint("Usage: gapcalc <font>\n"); - - if(!(dpy = XOpenDisplay(0))) - eprint("fatal: cannot open display\n"); - - fontstr = argv[1]; - missing = NULL; - - set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); - if(missing) - XFreeStringList(missing); - if(set) { - XFontSetExtents *font_extents; - XFontStruct **xfonts; - char **font_names; - ascent = descent = 0; - font_extents = XExtentsOfFontSet(set); - n = XFontsOfFontSet(set, &xfonts, &font_names); - for(i = 0, ascent = 0, descent = 0; i < n; i++) { - if(ascent < (*xfonts)->ascent) - ascent = (*xfonts)->ascent; - if(descent < (*xfonts)->descent) - descent = (*xfonts)->descent; - xfonts++; - } - } else if(!set && (xfont = XLoadQueryFont(dpy, fontstr))) { - ascent = xfont->ascent; - descent = xfont->descent; - } else - eprint("fatal: cannot find specified font\n"); - - printf("%d\n", ascent + descent + 2); - - - return EXIT_SUCCESS; -} - |