mirror of
https://github.com/tat3r/tdfiglet.git
synced 2025-06-08 15:39:55 +00:00
Add default path or file extension as required
This commit is contained in:
parent
6a6301de5f
commit
4171e4dc54
22
tdfiglet.c
22
tdfiglet.c
@ -40,6 +40,14 @@
|
|||||||
#define ENC_UNICODE 0
|
#define ENC_UNICODE 0
|
||||||
#define ENC_ANSI 1
|
#define ENC_ANSI 1
|
||||||
|
|
||||||
|
#ifndef FONT_DIR
|
||||||
|
#define FONT_DIR "fonts"
|
||||||
|
#endif /* FONT_DIR */
|
||||||
|
|
||||||
|
#ifndef FONT_EXT
|
||||||
|
#define FONT_EXT "tdf"
|
||||||
|
#endif /* FONT_EXT */
|
||||||
|
|
||||||
typedef struct opt_s {
|
typedef struct opt_s {
|
||||||
uint8_t justify;
|
uint8_t justify;
|
||||||
uint8_t width;
|
uint8_t width;
|
||||||
@ -198,7 +206,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
font_t
|
font_t
|
||||||
*loadfont(char *fn) {
|
*loadfont(char *fn_arg) {
|
||||||
|
|
||||||
font_t *font;
|
font_t *font;
|
||||||
uint8_t *map = NULL;
|
uint8_t *map = NULL;
|
||||||
@ -206,9 +214,20 @@ font_t
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
size_t len;
|
size_t len;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
char *fn = strdup("");
|
||||||
|
|
||||||
const char *magic = "\x13TheDraw FONTS file\x1a";
|
const char *magic = "\x13TheDraw FONTS file\x1a";
|
||||||
|
|
||||||
|
if (!strchr(fn_arg, '/')) {
|
||||||
|
if (strchr(fn_arg, '.')) {
|
||||||
|
sprintf(fn, "%s/%s", FONT_DIR, fn_arg);
|
||||||
|
} else {
|
||||||
|
sprintf(fn, "%s/%s.%s", FONT_DIR, fn_arg, FONT_EXT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strcpy(fn, fn_arg);
|
||||||
|
}
|
||||||
|
|
||||||
fd = open(fn, O_RDONLY);
|
fd = open(fn, O_RDONLY);
|
||||||
|
|
||||||
if (opt.info) {
|
if (opt.info) {
|
||||||
@ -303,6 +322,7 @@ font_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(fn);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user