Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Swift - NSFontManager availableFonts

Hi,


I am working on a swift project.


I try to get the available fonts, but the various trials I made were unsuccessful.


From the documentation, I believed that one of the following lines would work :


let allFontsName = NSFontManager.availableFonts


or var availableFonts: [AnyObject] { get }


How can I do ?


Thanks,

Nicolas

Posted on Jul 31, 2015 11:45 PM

Reply
Question marked as Best reply

Posted on Aug 2, 2015 7:02 AM

The Xcode editor should be giving you an idea of what the problem is with its "NSFontManager does not have a member named ..." error message. In this case, you need to be using the sharedFontManager, which returns the shared instance of the font manager for your application:


        let allFontNames = NSFontManager.sharedFontManager().availableFonts
        println(allFontNames)
2 replies
Question marked as Best reply

Aug 2, 2015 7:02 AM in response to Nicolas Silvestre

The Xcode editor should be giving you an idea of what the problem is with its "NSFontManager does not have a member named ..." error message. In this case, you need to be using the sharedFontManager, which returns the shared instance of the font manager for your application:


        let allFontNames = NSFontManager.sharedFontManager().availableFonts
        println(allFontNames)

Swift - NSFontManager availableFonts

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.