From 1f85d7f0c9d3cf2f552a3891417e459c46bac6a1 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Fri, 23 Aug 2019 16:44:57 -0700 Subject: [PATCH] Fix problem with fontdir option in .sfrotzrc not being honored for .bdf fonts. --- src/sdl/sf_fonts.c | 19 ++++++++++++++++--- src/sdl/sf_frotz.h | 4 ++++ src/sdl/sf_ftype.c | 4 +--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/sdl/sf_fonts.c b/src/sdl/sf_fonts.c index 7444392..afab5bc 100644 --- a/src/sdl/sf_fonts.c +++ b/src/sdl/sf_fonts.c @@ -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; diff --git a/src/sdl/sf_frotz.h b/src/sdl/sf_frotz.h index 22e6aaa..8561223 100644 --- a/src/sdl/sf_frotz.h +++ b/src/sdl/sf_frotz.h @@ -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 diff --git a/src/sdl/sf_ftype.c b/src/sdl/sf_ftype.c index d49f43d..af6de46 100644 --- a/src/sdl/sf_ftype.c +++ b/src/sdl/sf_ftype.c @@ -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 -- 2.34.1