diff options
author | Michael Pavone <pavone@retrodev.com> | 2020-04-18 23:07:44 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2020-04-18 23:07:44 -0700 |
commit | 6f24fe6971e31837abecb3367967ddc8d8c103dd (patch) | |
tree | a31e7f37239c53b1a57a854cb02e1a490fb288e2 | |
parent | 897b2c899f7932e6ac4842765fd3a870f5201901 (diff) |
Allow specifying a default font path at build time
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | nuklear_ui/font.c | 8 |
2 files changed, 12 insertions, 0 deletions
@@ -255,6 +255,10 @@ ifdef DATA_PATH CFLAGS+= -DDATA_PATH='"'$(DATA_PATH)'"' endif +ifdef FONT_PATH +CFLAGS+= -DFONT_PATH='"'$(FONT_PATH)'"' +endif + ALL=dis$(EXE) zdis$(EXE) stateview$(EXE) vgmplay$(EXE) blastem$(EXE) ifneq ($(OS),Windows) ALL+= termhelper diff --git a/nuklear_ui/font.c b/nuklear_ui/font.c index ff86847..8dde3d0 100644 --- a/nuklear_ui/font.c +++ b/nuklear_ui/font.c @@ -1,11 +1,19 @@ #include <stdio.h> #include <stdlib.h> #include <stdint.h> +#include <string.h> #include "../util.h" #include "sfnt.h" char *default_font_path(void) { +#ifdef FONT_PATH + FILE *f = fopen(FONT_PATH, "rb"); + if (f) { + fclose(f); + return strdup(FONT_PATH); + } +#endif FILE *fc_pipe = popen("fc-match -f '%{file}'", "r"); if (!fc_pipe) { return NULL; |