From f339eef8f5596e4d502a51ef389cee24dac78b98 Mon Sep 17 00:00:00 2001 From: insofaras Date: Sun, 4 Sep 2016 22:24:48 +0100 Subject: [PATCH] linux error popup for missing fonts --- linux_4ed.cpp | 1 + linux_font.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/linux_4ed.cpp b/linux_4ed.cpp index 6cf30b31..ce43514c 100644 --- a/linux_4ed.cpp +++ b/linux_4ed.cpp @@ -284,6 +284,7 @@ internal int LinuxHandleToFD(Plat_Handle); internal void LinuxStringDup(String*, void*, size_t); internal void LinuxToggleFullscreen(Display*, Window); +internal void LinuxFatalErrorMsg(const char* msg); internal Sys_Acquire_Lock_Sig(system_acquire_lock); internal Sys_Release_Lock_Sig(system_release_lock); diff --git a/linux_font.cpp b/linux_font.cpp index e5f38d09..9f69b4ac 100644 --- a/linux_font.cpp +++ b/linux_font.cpp @@ -69,6 +69,16 @@ linux_font_load(Partition *part, Render_Font *rf, char *name, i32 pt_size, i32 t #endif if (filename != 0){ + struct stat st; + if(stat(filename, &st) == -1 || S_ISDIR(st.st_mode)){ + char buff[1024]; + + // NOTE(inso): if/when you can load fonts from anywhere, the message should be changed. + snprintf(buff, sizeof(buff), "Unable to load font '%s'. Make sure this file is in the same directory as the '4ed' executable.", filename); + LinuxFatalErrorMsg(buff); + exit(1); + } + result = font_load_freetype(part, rf, filename, pt_size, tab_width, use_hinting); }