From 16332bd57b86edebaefa83c6ca8fb3d04048e93d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 18 Jul 2019 14:40:08 -0400 Subject: font_list(): New function --- diff --git a/src/font.c b/src/font.c index 30d51c9..719d7ff 100644 --- a/src/font.c +++ b/src/font.c @@ -22,6 +22,7 @@ #include "font.h" #include +#include #include #include @@ -47,6 +48,16 @@ static const struct font_desc *fonts[] = { &font_mplus_1mn_regular_16x22, }; +void +font_list(FILE *stream) +{ + size_t i; + + for (i = 0; i < *(&fonts + 1) - fonts; ++i) { + fprintf(stream, "%s\n", fonts[i]->name); + } +} + struct font * font_default(void) { diff --git a/src/font.h b/src/font.h index c1abe26..4cd7da1 100644 --- a/src/font.h +++ b/src/font.h @@ -22,10 +22,15 @@ #ifndef FONT_H_ #define FONT_H_ +#include + #include #include +void +font_list(FILE *stream); + struct font * font_default(void) __attribute__((pure)); diff --git a/src/main.c b/src/main.c index 411902c..e6fdada 100644 --- a/src/main.c +++ b/src/main.c @@ -60,6 +60,10 @@ main(int argc, char **argv) while ((opt = getopt(argc, argv, "f:w:h:")) != -1) { switch (opt) { case 'f': + if (strcmp(optarg, "list") == 0) { + font_list(stdout); + return 0; + } font = font_find(optarg); if (!font) { fprintf(stderr, _("Font \"%s\" not " -- cgit v0.9.1