Skip to content

Instantly share code, notes, and snippets.

@keighl
Created January 12, 2016 16:19
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/b7c4ea235486c1dd4c3f to your computer and use it in GitHub Desktop.
Save keighl/b7c4ea235486c1dd4c3f to your computer and use it in GitHub Desktop.
func textViewDidChangeTypingAttributes(notification: NSNotification) {
if let font = textView?.typingAttributes[NSFontAttributeName] as? NSFont {
if let faces = NSFontManager.sharedFontManager().availableMembersOfFontFamily(font.familyName) {
// faces is an array of arrays like this:
// [[Helvetica, Regular, 5, 0], [Helvetica-Light, Light, 3, 0], [Helvetica-Oblique, Oblique, 5, 1], [Helvetica-LightOblique, Light Oblique, 3, 1], [Helvetica-Bold, Bold, 9, 2], [Helvetica-BoldOblique, Bold Oblique, 9, 3]]
fontFacesLabels = faces.map({face in (face[1] as! String)})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment