commit 96ef4ccfe08c0ae657c79ea54608958a256fb33f
parent d251ee663e6b980a688e3cd6e2dbc4d4b5a9b7aa
Author: Frederic Cambus <fred@statdns.com>
Date: Thu, 17 Sep 2020 21:39:14 +0200
Avoid duplicating custom font selection logic.
Diffstat:
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/ansilove.c b/src/ansilove.c
@@ -119,12 +119,6 @@ main(int argc, char *argv[])
break;
case 'f':
font = optarg;
- for (size_t loop = 0; loop < FONTS; loop++) {
- if (!strcmp(fonts[loop], font)) {
- options.font = fontsId[loop];
- break;
- }
- }
break;
case 'h':
synopsis();
@@ -304,18 +298,21 @@ main(int argc, char *argv[])
if (strcmp(record->tinfos, "Amiga Topaz 2+") == 0) {
font = "topaz+";
}
- for (size_t loop = 0; loop < FONTS; loop++) {
- if (!strcmp(fonts[loop], font)) {
- options.font = fontsId[loop];
- break;
- }
- }
}
if (usedSAUCE) {
fprintf(messages, "SAUCE info used for rendering hints\n\n");
}
}
+ if (font) {
+ for (size_t loop = 0; loop < FONTS; loop++) {
+ if (!strcmp(fonts[loop], font)) {
+ options.font = fontsId[loop];
+ break;
+ }
+ }
+ }
+
/* create output file name if output is not specified */
if (!output) {
/* appending ".png" extension to output file name */