diff options
Diffstat (limited to 'src/font.c')
-rw-r--r-- | src/font.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -48,12 +48,30 @@ static const struct font_desc *fonts[] = { }; struct font * +font_default(void) +{ + struct font *font; + int pref; + size_t i; + + font = NULL; + pref = -10000; + for (i = 0; i < *(&fonts + 1) - fonts; ++i) { + if (fonts[i]->pref > pref) { + font = (struct font *) fonts[i]; + pref = fonts[i]->pref; + } + } + return font; +} + +struct font * font_find(const char *name) { size_t i; if (!name) { - return (struct font *) fonts[0]; + return NULL; } for (i = 0; i < *(&fonts + 1) - fonts; ++i) { @@ -61,7 +79,7 @@ font_find(const char *name) return (struct font *) fonts[i]; } } - return (struct font *) fonts[0]; + return NULL; } int |