From 1bd1c7233ffcdff4376e2dda27aa9957c7bf54a8 Mon Sep 17 00:00:00 2001 From: Martin Fuhrer Date: Thu, 7 Feb 2008 04:11:04 +0000 Subject: [PATCH] Mac OS X font loading fix: Skip over system font "AppleMyungjo.ttf" which causes TTF_OpenFont() to crash. --- src/fonts.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fonts.c b/src/fonts.c index 189617240..7ca5e10dc 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -31,6 +31,12 @@ #ifdef __APPLE__ #include "wrapperdata.h" extern WrapperData macosx; + +/* system fonts that cause TTF_OpenFont to crash */ +static const char* problemFonts[] = { + "/Library/Fonts//AppleMyungjo.ttf", + NULL +}; #endif #ifdef FORKED_FONTS @@ -284,9 +290,19 @@ TuxPaint_Font * TuxPaint_Font_OpenFont(const char * pangodesc, const char * ttff if (ttffilename != NULL && ttffilename[0] != '\0') { + int i; #ifdef DEBUG printf("Opening TTF\n"); fflush(stdout); #endif + +#ifdef __APPLE__ + i = 0; + while (problemFonts[i] != NULL) + { + if (!strcmp(ttffilename, problemFonts[i++])) + return NULL; /* bail on known problematic fonts that cause TTF_OpenFont to crash */ + } +#endif tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font)); tpf->typ = FONT_TYPE_TTF;