Skip to content

Instantly share code, notes, and snippets.

@keighl
Created January 12, 2016 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keighl/f923080c41fb896c9060 to your computer and use it in GitHub Desktop.
Save keighl/f923080c41fb896c9060 to your computer and use it in GitHub Desktop.
dynamic let fontFamilyNames = NSFontManager.sharedFontManager().availableFontFamilies
fontFamilyName!.bind("content", toObject: self, withKeyPath: "fontFamilyNames", options: nil)
@IBAction func fontFamilyChanged(sender: NSPopUpButton) {
let newIDX = sender.indexOfSelectedItem
if var font = textView?.typingAttributes[NSFontAttributeName] as? NSFont {
font = NSFontManager.sharedFontManager().convertFont(font, toFamily: fontFamilyNames[newIDX])
applyNewAttributes([NSFontAttributeName: font])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment