2

I can't get selected font in NSFontManager. What I need:

1) I need to get selected font title, size, color?

I am calling NSFontManager with button like this:

[[NSFontManager sharedFontManager] orderFrontFontPanel:self];

It's opening but I don't know how to get selected font. As string for example: Verdana.

I have read apple's docs but I can't understand how to get what font is selected. I'm not changing or converting any fonts. I just need to get what font was selected.

  • 1
    Are you using the `-setTarget:`, `-setAction:`, and `-selectedFont` methods of NSFontManager? – bneely Feb 22 '12 at 08:50

1 Answers1

1
NSString *selectedFontName = [[[NSFontManager sharedFontManager] selectedFont] displayName];

(depending on your intended use, you may want to use fontName instead of displayName.)

omz
  • 53,243
  • 5
  • 129
  • 141
  • Thanks, that helped me a lot! now I can get font name. But how to get font's color? –  Feb 22 '12 at 11:16
  • The color has nothing to do with the font. Look at the documentation about `NSTextView`, `NSTextStorage` and `NSAttributedString`. – omz Feb 22 '12 at 15:34
  • 2
    But at the top panel is "Text underline" "Text strikethrough" "Text color" this all is used for NSTextView yes? Thanks for information. –  Feb 22 '12 at 18:24