commit 076492a

chld  ·  2026-07-13 22:22:33 +0000 UTC
parent d219f57
load a custom font
1 files changed,  +11, -3
M xl.c
M xl.c
+11, -3
 1@@ -24,8 +24,10 @@ int main(int ac, char **av) {
 2   char path[128];
 3   snprintf(path, sizeof path, "%s/%s", getenv("HOME"), ".xlrc");
 4 
 5+  char *fnt = NULL;
 6+
 7   int opt;
 8-  while ((opt = getopt(ac, av, "c:g:h ")) != -1) {
 9+  while ((opt = getopt(ac, av, "c:g:f:h ")) != -1) {
10     switch (opt) {
11     case 'c':
12       snprintf(path, sizeof path, "%s", optarg);
13@@ -41,9 +43,13 @@ int main(int ac, char **av) {
14       hi = atoi(p + 1);
15       break;
16     }
17+    case 'f':
18+      fnt = optarg;
19+      break;
20     case 'h':
21       fprintf(stderr,
22-              "usage: %s [-c file] [-g WxH]\nusage: %s [-h]\nusage: %s\n",
23+              "usage: %s [-c file] [-g WxH] [-f fontname]\nusage: %s "
24+              "[-h]\nusage: %s\n",
25               av[0], av[0], av[0]);
26       return 0;
27       break;
28@@ -106,7 +112,9 @@ int main(int ac, char **av) {
29   XFillRectangle(d, w, gc, 0, 0, wi, hi);
30   XSetForeground(d, gc, BlackPixel(d, s));
31 
32-  XFontStruct *font = XLoadQueryFont(d, "fixed");
33+  XFontStruct *font = XLoadQueryFont(d, fnt ? fnt : "fixed");
34+  if (!font)
35+    font = XLoadQueryFont(d, "fixed");
36   XSetFont(d, gc, font->fid);
37 
38   int32_t sel = 0;