Skip to content

Demo macOS project demonstrating how to use NSFontPanel

Notifications You must be signed in to change notification settings

fluffyes/NSFontPanelDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSFontPanelDemo

Sample macOS Cocoa app Xcode project demonstrating how to use NSFontPanel to let user change font.

demo

The key is to implement the changeFont(_ sender: Any?) function in your view controller, or in the NSWindowController, AppDelegate that is placed above in the Responder Chain.

override func changeFont(_ sender: Any?) {

  // the sender is a font manager
  guard let fontManager = sender as? NSFontManager else {
    return
  }
	
  // the newly selected font
  /*
  	you can actually pass in any font into the .convert() function and it
  	will return the selected font from the panel, lol
  */
	
//  let newFont = fontManager.convert(NSFont.systemFont(ofSize: 13.0))
  let newFont = fontManager.convert(self.font)
  yourLabel.font = newFont
}

About

Demo macOS project demonstrating how to use NSFontPanel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages