Hi,
Can anyone point me to the proper way of calling this method of NSFontManager:
- (NSArray *)availableFonts;
to get the list of active fonts?
As a list, string or whatever else is digestable by AppleScript.
I was successfull to call various methods before (well, mostly from samples), but am lost when it comes to this one.
Any help will be appreciated.
And also wanted to thank Dennis for helping me to bring file attributes into FileMaker long time ago - it helped me a lot and I didn’t get a chance to acknowledge it back then.
Thanks,
Leo
Hi Leo,
is there no AppleScript solution to get a list of all fonts? Hmmm anyway - if you want to use the availableFonts method then:
-
Add a new File in your xCode project of type ‘Cocoa/Objective-C class’ - name it: ‘MyFontlist’
-
you now see two additional files called MyFontlist.h and MyFontlist.m - edit them that the look like so:
MyFontlist.h:
#import <Cocoa/Cocoa.h>
@interface MyFontlist : NSObject {}
+(NSArray *)MyFontlist;
@end
MyFontlist.m:
#import "MyFontlist.h"
@implementation MyFontlist
+(NSArray *)MyFontlist {
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSArray *theList = [fontManager availableFonts];
[fontManager release];
[theList retain];
[theList release];
return theList;
}
@end
then you can call this method from your script:
set thelist to (call method "MyFontlist" of class "MyFontlist")
Of course you are free to name method and clas to whatever you like ‘MyFontlist’ is just an example.
D.
I think this is the syntax:
set sFM to (call method "sharedFontManager" of class "NSFontManager")
call method "availableFonts" of sFM
Fantastic! Thanks a lot, Dominic!
And BTW, that’s true, there’s no way to get the list of active font with AppleScript, as far as I know at least.
Leo
Not vanilla, but you can use these (OS X), appart from the mentioned “call method”:
http://osaxen.com/files/fontmenu1.0.html
http://osaxen.com/files/extrasuites1.1.html
Hmmm… And this one:
tell application "Smile" to (get its «class FLST»)
(And I’m sure there are more ones)