summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-07-18 14:40:08 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-07-18 14:40:08 (EDT)
commit16332bd57b86edebaefa83c6ca8fb3d04048e93d (patch)
tree283397d9d80cd261402933f3d536e33abe946baa
parenteb7115b77e55fb049edd5582b114eefb246edf40 (diff)
font_list(): New function
-rw-r--r--src/font.c11
-rw-r--r--src/font.h5
-rw-r--r--src/main.c4
3 files changed, 20 insertions, 0 deletions
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 <limits.h>
+#include <stdio.h>
#include <string.h>
#include <png.h>
@@ -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 <stdio.h>
+
#include <png.h>
#include <linux/font.h>
+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 "