[AD] [patch] make load_txt_font() find files in script in the script's dir

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I want to store the font files mentioned in the script in the same directory as the script itself, but load_txt_font() only supports absolute paths or paths relative to CWD.
Index: src/fonttxt.c
===================================================================
--- src/fonttxt.c	(revision 7542)
+++ src/fonttxt.c	(working copy)
@@ -27,6 +27,7 @@
 FONT *load_txt_font(AL_CONST char *filename, RGB *pal, void *param)
 {
    char buf[1024], *font_str, *start_str = 0, *end_str = 0;
+   char font_filename[1024];
    FONT *f, *f2, *f3, *f4;
    PACKFILE *pack;
    int begin, end, glyph_pos=32;
@@ -75,7 +76,15 @@
       if (font_str[0]) {
          if (f2)
             destroy_font(f2);
-         f2 = load_font(font_str, pal, param);
+         if (exists(font_str))
+            f2 = load_font(font_str, pal, param);
+         else if (is_relative_filename(font_str)) {
+            replace_filename(font_filename, filename, font_str,
+                             sizeof(font_filename));
+            f2 = load_font(font_filename, pal, param);
+         }
+         else
+            f2 = NULL;
          if (f2) glyph_pos=get_font_range_begin(f2, -1);
       }
       if(!f2) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/