diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-11-21 19:07:43 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-11-21 19:07:43 -0800 |
commit | 2ef80983d5d11aec60c4a4fbe0958a261e42fb6b (patch) | |
tree | d16639e745d96ac0b7c0e83a5e923850ad4c2343 /nuklear_ui/font.c | |
parent | c5f80591a0f8cbc2a6a3ab30b28754a16042c6f3 (diff) |
Initial work on Nuklear-based UI
--HG--
branch : nuklear_ui
Diffstat (limited to 'nuklear_ui/font.c')
-rw-r--r-- | nuklear_ui/font.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/nuklear_ui/font.c b/nuklear_ui/font.c new file mode 100644 index 0000000..6dd3232 --- /dev/null +++ b/nuklear_ui/font.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <stdlib.h> + +char *default_font_path(void) +{ + FILE *fc_pipe = popen("fc-match -f '%{file}'", "r"); + if (!fc_pipe) { + return NULL; + } + size_t buf_size = 128; + char *buffer = NULL; + size_t total = 0, read = 0; + do { + total += read; + buf_size *= 2; + buffer = realloc(buffer, buf_size); + if (!buffer) { + return NULL; + } + read = fread(buffer, 1, buf_size - total, fc_pipe); + } while (read == (buf_size - total)); + total += read; + buffer[total] = 0; + + return buffer; +} |