I am making an app where users will be able to add their own fonts.
I am trying to use Core Text CTFontManagerIsSupportedFontFile to check the validity of a font file prior to install it, to avoid messing up the system.
Problem is, it crashes. I am applying the very same approach as I do for CTFontManagerRegisterFontsForURL which works perfectly and pass the same URL, so I was expecting it to work fairly easily.
[code] const kCTFontManagerScopeNone = 0
const kCTFontManagerScopeProcess = 1
const kCTFontManagerScopeUser = 2
const kCTFontManagerScopeSession = 3
dim f as FolderItem = specialfolder.GetResource(“Calebasse.ttf”)
if f <> nil then
declare function CFURLCreateWithString lib "CoreFoundation" ( allocator as Ptr, URLString as CFStringRef, BaseURL as Ptr ) as Ptr
dim cfstr as CFStringRef = f.URLPath
Dim CFUrlRef as Ptr = CFURLCreateWithString( nil, cfstr,nil )
declare function CTFontManagerIsSupportedFontFile lib "CoreText" (fontURL as Ptr ) as boolean
if CTFontManagerIsSupportedFontFile( CFURLRef) then
msgbox "OK"
else
msgbox "Yuk"
end if
[/code]
Here is what I get in the simulator console :
Jan 24 22:36:19 Mitchs-iMac com.apple.CoreSimulator.SimDevice.0B3D6660-CD33-44C2-B62D-212CCB95EAB4.launchd_sim[2751] (UIKitApplication:com.matchsoftware.fontname[0xc2fa][3166]): Service exited due to signal: Trace/BPT trap: 5
Jan 24 22:36:19 Mitchs-iMac.local SpringBoard[2763]: Application 'UIKitApplication:com.matchsoftware.fontname[0xc2fa]' crashed.
Jan 24 22:36:19 Mitchs-iMac assertiond[2767]: assertion failed: 14B25 12B411: assertiond + 13690 [F3233EFE-D6AB-32E3-BB3E-2CC6D0333C88]: 0x1
Jan 24 22:36:19 Mitchs-iMac.local assertiond[2767]: notify_suspend_pid() failed with error 7
Jan 24 22:36:19 Mitchs-iMac assertiond[2767]: assertion failed: 14B25 12B411: assertiond + 13690 [F3233EFE-D6AB-32E3-BB3E-2CC6D0333C88]: 0x1
There is a mystery, though. In the iOS and Mac developer library, it shows now :
[quote]Validating Font Files
1 Objective-C symbol hidden[/quote]
When a few months back, it said :
[quote]CTFontManagerIsSupportedFontFile
Determines whether the referenced font data (usually by file URL) is supported on the current platform.[/quote]
[quote]bool CTFontManagerIsSupportedFont(CFURLRef fontURL);
Parameters
fontURL
A URL referring to font data.[/quote]
[quote]Return Value
Returns true if the URL refers to a valid font that can be used on the current platform; false otherwise.[/quote]
So has Apple simply removed that function altogether, or is there something I do not see ?
I know this is fairly specialized stuff, but any help will be appreciated.