#include "image.h"
#include "vec3.h"
#include "gui.h"
+#include "common.h"
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
+static const char *pick_font_path(void)
+{
+ const char *path;
+
+ path = config_data(_(GUI_FACE));
+
+ if (!file_exists(path))
+ {
+ fprintf(stderr, _("Font \"%s\" doesn't exist, trying default font.\n"),
+ path);
+
+ path = config_data(GUI_FACE);
+ }
+
+ return path;
+}
+
void gui_init(void)
{
const float *c0 = gui_yel;
if (TTF_Init() == 0)
{
+ const char *fontpath = pick_font_path();
+
int s0 = s / 26;
int s1 = s / 13;
int s2 = s / 7;
/* Load small, medium, and large typefaces. */
- font[GUI_SML] = TTF_OpenFont(config_data(GUI_FACE), s0);
- font[GUI_MED] = TTF_OpenFont(config_data(GUI_FACE), s1);
- font[GUI_LRG] = TTF_OpenFont(config_data(GUI_FACE), s2);
+ font[GUI_SML] = TTF_OpenFont(fontpath, s0);
+ font[GUI_MED] = TTF_OpenFont(fontpath, s1);
+ font[GUI_LRG] = TTF_OpenFont(fontpath, s2);
radius = s / 60;
/* Initialize digit glyphs and lists for counters and clocks. */
/*---------------------------------------------------------------------------*/
-#define GUI_FACE _("ttf/DejaVuSans-Bold.ttf")
+#define GUI_FACE N_("ttf/DejaVuSans-Bold.ttf")
#define GUI_SML 0
#define GUI_MED 1