src/font.c

changeset 86
943bf9d7c6d6
parent 83
f7ce0db6f72b
child 88
6234b7ea48f3
--- a/src/font.c	Sat Apr 19 13:00:32 2025 +0200
+++ b/src/font.c	Sat Apr 19 15:06:24 2025 +0200
@@ -25,9 +25,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "ascension/ui/font.h"
 #include "ascension/context.h"
 #include "ascension/error.h"
+#include "ascension/filesystem.h"
+#include "ascension/ui/font.h"
 
 #include <assert.h>
 #include <cx/array_list.h>
@@ -40,13 +41,13 @@
 static char const *asc_font_filename(enum AscFontStyle style) {
     switch (style) {
         case ASC_FONT_REGULAR:
-            return "fonts/OpenSans-Regular.ttf";
+            return "OpenSans-Regular.ttf";
         case ASC_FONT_BOLD:
-            return "fonts/OpenSans-Bold.ttf";
+            return "OpenSans-Bold.ttf";
         case ASC_FONT_ITALIC:
-            return "fonts/OpenSans-Italic.ttf";
+            return "OpenSans-Italic.ttf";
         case ASC_FONT_BOLD_ITALIC:
-            return "fonts/OpenSans-BoldItalic.ttf";
+            return "OpenSans-BoldItalic.ttf";
         default:
             assert(false);
             return NULL;
@@ -78,7 +79,6 @@
     cxListFree(asc_font_cache);
 }
 
-
 TTF_Font *asc_font_load(AscFont font) {
     CxIterator iter = cxListIterator(asc_font_cache);
     cx_foreach(struct asc_font_cache_entry*, cache, iter) {
@@ -89,7 +89,9 @@
 
     struct asc_font_cache_entry entry;
     entry.font = font;
-    entry.ttf = TTF_OpenFont(asc_font_filename(font.style), font.size);
+    cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.font_path), cx_str(asc_font_filename(font.style)));
+    entry.ttf = TTF_OpenFont(fpath.ptr, font.size);
+    cx_strfree(&fpath);
     if (entry.ttf == NULL) {
         asc_error(TTF_GetError());
         return NULL;

mercurial