File diff r21584:561d516cfa45 → r21585:c96bdc9bd57c
src/fontdetection.cpp
Show inline comments
 
@@ -375,49 +375,49 @@ bool SetFallbackFont(FreeTypeSettings *s
 

	
 
#include "os/macosx/macos.h"
 

	
 
#include "safeguards.h"
 

	
 
FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
 
{
 
	FT_Error err = FT_Err_Cannot_Open_Resource;
 

	
 
	/* Get font reference from name. */
 
	CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, font_name, kCFStringEncodingUTF8);
 
	ATSFontRef font = ATSFontFindFromName(name, kATSOptionFlagsDefault);
 
	CFRelease(name);
 
	if (font == kInvalidFont) return err;
 

	
 
	/* Get a file system reference for the font. */
 
	FSRef ref;
 
	OSStatus os_err = -1;
 
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
 
	if (MacOSVersionIsAtLeast(10, 5, 0)) {
 
		os_err = ATSFontGetFileReference(font, &ref);
 
	} else
 
#endif
 
	{
 
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !__LP64__
 
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !defined(__LP64__)
 
		/* This type was introduced with the 10.5 SDK. */
 
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
 
	#define ATSFSSpec FSSpec
 
#endif
 
		FSSpec spec;
 
		os_err = ATSFontGetFileSpecification(font, (ATSFSSpec *)&spec);
 
		if (os_err == noErr) os_err = FSpMakeFSRef(&spec, &ref);
 
#endif
 
	}
 

	
 
	if (os_err == noErr) {
 
		/* Get unix path for file. */
 
		UInt8 file_path[PATH_MAX];
 
		if (FSRefMakePath(&ref, file_path, sizeof(file_path)) == noErr) {
 
			DEBUG(freetype, 3, "Font path for %s: %s", font_name, file_path);
 
			err = FT_New_Face(_library, (const char *)file_path, 0, face);
 
		}
 
	}
 

	
 
	return err;
 
}
 

	
 
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
 
{