I am trying to get a list of all the fonts installed on a device. This list is not fixed. It varies according to the system version, and also, fonts can be installed.
I have found this in Objective-C :
http://www.developerfeed.com/how-list-all-fonts-available-ios-platform
[code]// array
NSMutableArray *fontNames = [[NSMutableArray alloc] init];
// get font family
NSArray *fontFamilyNames = [UIFont familyNames];
// loop
for (NSString *familyName in fontFamilyNames)
{
NSLog(@“Font Family Name = %@”, familyName);
// font names under family
NSArray *names = [UIFont fontNamesForFamilyName:familyName];
NSLog(@“Font Names = %@”, fontNames);
// add to array
[fontNames addObjectsFromArray:names];
}
[fontNames release];[/code]
If I read this correctly, the method first reads all the font families, then for each family all the font names (Times Bold, Times Italic and so on I guess).
I looked at the UIFont class reference at https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIFont_Class/ and used Jason King’s Declare Maker to create the necessary declares.
Now I have picked up the methods from what the
[code] Shared Function FamilyNames() As NSArray
declare function familyNames_ lib UIKitLib selector “familyNames” (clsRef as ptr) as ptr
Return new NSArray(familyNames_(ClassRef))
End Function
Shared Function FontNamesForFamilyName(familyName as CFStringRef) As NSArray
declare function fontNamesForFamilyName_ lib UIKitLib selector “fontNamesForFamilyName:” (clsRef as ptr, familyName as CFStringRef) as ptr
Return new NSArray(fontNamesForFamilyName_(ClassRef, familyName))
End Function
[/code]
Now I am lost.
- Where do I get ClassRef ? What is it ? How do I create it ?
- Can I use the same code as in https://forum.xojo.com/19262-get-back-a-cfarray-from-a-declare to get the arrays ? Is an NSArray equivalent to a CFArray ? If not, how do I get it ?
Any help will be greatly appreciated.