Fix problem with fontdir option in .sfrotzrc not being honored for .bdf fonts.
authorDavid Griffith <dave@661.org>
Fri, 23 Aug 2019 23:44:57 +0000 (16:44 -0700)
committerDavid Griffith <dave@661.org>
Sat, 24 Aug 2019 00:33:20 +0000 (17:33 -0700)
src/sdl/sf_fonts.c
src/sdl/sf_frotz.h
src/sdl/sf_ftype.c

index 74443925e2ccc0793171d4624b1b8efc5fc256d6..afab5bc6c8061ef180aebb0aa037efee172debe8 100644 (file)
@@ -717,16 +717,29 @@ void (*ttfontsdone)() = NULL;
 
 static SFONT *tryloadfont( char *fspec, SFONT *like)
   {
-  int err,size;
-  char *p;
+  char buf[FILENAME_MAX];
+  int err,size = DEFSIZE;
+  char *p, *fn, *at;
+  int fnlen=-1;
   SFONT *b = NULL;
+
+  at = strchr(fspec, '@');
+  if (at) {
+    fnlen = at - fspec;
+    size = atoi(at+1);
+  }
+
+  if (m_fontdir != NULL)
+    fn = sf_searchfile(fspec, fnlen, buf, m_fontdir);
+
   for (;;){
     p = strchr(fspec,'|');
     if (p) *p = 0;
+
     if (ttfontloader)
        b = ttfontloader(fspec, like, &err);
     if (!b)
-       b = loadfont(fspec,&err,&size);
+       b = loadfont(fn,&err,&size);
     if (b) break;
     if (p) { *p = '|'; fspec = p+1;}
     else break;
index 22e6aaa7bc7e1dd3017c8b828c2d539f6b612d1d..85612239281734f052f623dbcfb2a38215580654 100644 (file)
@@ -231,6 +231,8 @@ void sf_installhandlers(void);
 void sf_pushtextsettings(void);
 void sf_poptextsettings(void);
 
+char *sf_searchfile(char*, int, char *, char *);
+
 void sf_chline( int x, int y, ulong c, int n);
 void sf_cvline( int x, int y, ulong c, int n);
 bool sf_flushdisplay(void);
@@ -248,6 +250,8 @@ void sf_FinishProfile(void);
 #define OS_PATHSEP ':'
 #endif
 
+#define DEFSIZE 14
+
 // virtual keys
 #define VK_TAB 0x16
 #define VK_INS 0x17
index d49f43d2df21a2b4e9fac5a9129ca81ff5be7619..af6de4627f9285dda539d8c8906e9e5a7871f573 100644 (file)
@@ -12,7 +12,7 @@
 
 /////////////////////////////////////////////////////////////////
 
-static char * sf_searchfile( char *fn, int fnlen, char *buf, char *paths)
+char * sf_searchfile( char *fn, int fnlen, char *buf, char *paths)
   {
   char *p;
   if (!fn) return NULL;
@@ -258,8 +258,6 @@ static SFONT * loadftype( char *fname, int size, SFONT *like, int *err)
   return (SFONT *) res;
   }
 
-#define DEFSIZE 14
-
 #ifdef WIN32
 #define SYSFONTS "c:/windows/fonts"
 #else