fix fix some fonts not getting loaded on OSX

This commit is contained in:
UnknownShadow200 2018-10-31 19:16:22 +11:00
parent 75ceeda229
commit 4c63243c3b
4 changed files with 20 additions and 12 deletions

View File

@ -891,11 +891,11 @@ void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
/* For OSX font suitcase files */ /* For OSX font suitcase files */
#ifdef CC_BUILD_OSX #ifdef CC_BUILD_OSX
char fileBuffer[FILENAME_SIZE + 1]; char filenameBuffer[FILENAME_SIZE + 1];
String file = String_NT_Array(fileBuffer); String filename = String_NT_Array(filenameBuffer);
String_Copy(&file, &path); String_Copy(&filename, &path);
file.buffer[file.length] = '\0'; filename.buffer[filename.length] = '\0';
args.pathname = file.buffer; args.pathname = filename.buffer;
#endif #endif
err = FT_New_Face(ft_lib, &args, 0, &face); err = FT_New_Face(ft_lib, &args, 0, &face);
@ -948,7 +948,17 @@ static void Font_DirCallback(const String* path, void* obj) {
FT_Error err; FT_Error err;
if (!Font_MakeArgs(path, &stream, &args)) return; if (!Font_MakeArgs(path, &stream, &args)) return;
err = FT_Open_Face(ft_lib, &args, 0, &face);
/* For OSX font suitcase files */
#ifdef CC_BUILD_OSX
char filenameBuffer[FILENAME_SIZE + 1];
String filename = String_NT_Array(filenameBuffer);
String_Copy(&filename, path);
filename.buffer[filename.length] = '\0';
args.pathname = filename.buffer;
#endif
err = FT_New_Face(ft_lib, &args, 0, &face);
if (err) { stream.close(&stream); return; } if (err) { stream.close(&stream); return; }
if (face->style_flags == FT_STYLE_FLAG_BOLD) { if (face->style_flags == FT_STYLE_FLAG_BOLD) {

View File

@ -128,10 +128,7 @@ FT_BEGIN_HEADER
#ifdef ECANCELED /* defined since 10.2 */ #ifdef ECANCELED /* defined since 10.2 */
#include "AvailabilityMacros.h" #include "AvailabilityMacros.h"
#endif #endif
#if defined( __LP64__ ) && \ #define FT_MACINTOSH 1
( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
#undef FT_MACINTOSH
#endif
#elif defined( __SC__ ) || defined( __MRC__ ) #elif defined( __SC__ ) || defined( __MRC__ )
/* Classic MacOS compilers */ /* Classic MacOS compilers */

View File

@ -987,7 +987,7 @@
return error; return error;
/* let it fall through to normal loader (.ttf, .otf, etc.) */ /* let it fall through to normal loader (.ttf, .otf, etc.) */
return FT_Open_Face( library, &args, face_index, aface ); return FT_Open_Face( library, args, face_index, aface );
} }

View File

@ -2221,7 +2221,6 @@
FT_Error error; FT_Error error;
FT_UNUSED( args ); FT_UNUSED( args );
error = IsMacBinary( library, stream, face_index, aface ); error = IsMacBinary( library, stream, face_index, aface );
if ( FT_ERR_EQ( error, Unknown_File_Format ) ) if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{ {
@ -2258,6 +2257,7 @@
/* documentation is in freetype.h */ /* documentation is in freetype.h */
#ifndef FT_MACINTOSH
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_New_Face( FT_Library library, FT_New_Face( FT_Library library,
const FT_Open_Args* args, const FT_Open_Args* args,
@ -2266,6 +2266,7 @@
{ {
return FT_Open_Face( library, args, face_index, aface ); return FT_Open_Face( library, args, face_index, aface );
} }
#endif
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_Open_Face( FT_Library library, FT_Open_Face( FT_Library library,