Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting NSTextView's Font



I would like my NSTextView to only use one font, Monaco 10-pt. In the
awakeFromNib method I have:


[[self textStorage] addAttribute:NSFontAttributeName value:[NSFont
fontWithName:@"Monaco" size:10.0] range:NSMakeRange(0, [[[self
textStorage] mutableString] length])];


But this does not work. My first thought was simply to set the font in
the nib itself, but it only works if the field also has text in it,
otherwise it defaults to Helvetica 12.

Is there something I'm missing?

Yes.Its works only if some text already exits. Otherwise the font is not applied. Because an attribute gets added only if text exits in that range exists. Since there is not text in the beginning the font does not apply.


If you want to apply default font , i think use should use setFont: in NSTextView class.
------------------------------------------------------------------------ --
Ramesh PVK
Programmer
effigent India Pvt. Ltd.
ⅱ Home : 040 27227830
: 040 31148951
------------------------------------------------------------------------ --
In a world without walls and fences, who does still need Windows and Gates ?
_______________________________________________
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.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.