Re: NSTextView and font sizes?
Re: NSTextView and font sizes?
- Subject: Re: NSTextView and font sizes?
- From: Douglas Davidson <email@hidden>
- Date: Tue, 21 Jan 2003 09:53:35 -0800
On Monday, January 20, 2003, at 10:09 PM, Alex Rice wrote:
I have subclassed NSTextView and am using insertText: to layout a
bunch of NSAttributedStrings. Like this
NSAttributedString *nameStr = [[[NSAttributedString alloc]
initWithString: name
attributes: attrs] autorelease];
[self insertText: nameStr];
attrs has a font object set for the key NSFontAttributeName. What I am
seeing is that the font is correctly rendered in the NSTextView, but
the font size is thrown out. The font size is definitely correct in
the font object that's set in attrs. What am I missing here?
That insertText: is not the right method for this. insertText: is the
funnel point for text entered by the user via the keyboard, whether
directly or through an input method. Usually when the user types text,
the attributes are taken from the typing attributes. In some cases an
input method for e.g. Chinese or Japanese may need to set a particular
font, but the font size is correctly still taken from the typing
attributes.
If you want to construct complex text programmatically, you should
probably be dealing with the model object, the NSTextStorage, rather
than with the view. NSTextStorage is a subclass of
NSMutableAttributedString, so you can use any of the mutable attributed
string methods to modify it. If you are making many changes at once,
wrap them in a beginEditing/endEditing pair for efficiency. See the
NSTextStorage documentation for more information.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.