Mercurial > repos > blastem
view nuklear_ui/font.c @ 1526:9bea1a199f15 nuklear_ui
Filled in About view
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 07 Feb 2018 19:21:44 -0800 |
parents | c5c022c7aa54 |
children | 4f6e8acd7b6a |
line wrap: on
line source
#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; }