- (void)updateMyTextViewTextAttributes { NSMutableParagraphStyle* paragraphStyle = [[myTextView defaultParagraphStyle] mutableCopy];
if (paragraphStyle == nil) { paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; } float charWidth = [[myFont screenFontWithRenderingMode:NSFontDefaultRenderingMode] advancementForGlyph:(NSGlyph) ' '].width; [paragraphStyle setDefaultTabInterval:(charWidth * 4)]; [paragraphStyle setTabStops:[NSArray array]]; [myTextView setDefaultParagraphStyle:paragraphStyle]; NSMutableDictionary* typingAttributes = [[myTextView typingAttributes] mutableCopy]; [typingAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; [typingAttributes setObject:scriptFont forKey:NSFontAttributeName]; [myTextView setTypingAttributes:typingAttributes]; NSRange rangeOfChange = NSMakeRange(0, [[myTextView string] length]); [myTextView shouldChangeTextInRange:rangeOfChange replacementString:nil]; [[myTextView textStorage] setAttributes:typingAttributes range:rangeOfChange]; [myTextView didChangeText]; } On Fri, Feb 19, 2010 at 12:35 PM, Douglas Davidson <ddavi...@apple.com> wrote: > > On Feb 19, 2010, at 9:03 AM, lyndsey.fergu...@gmail.com wrote: > >> I've tried calling my updateMyTextViewTextAttributes call when myTextView >> has the new myFont set. That doesn't change a thing. > > With updateMyTextViewTextAttributes as described, it will set the paragraph > style for new text but won't change the paragraph style for existing text. > What you would want to do would be to apply the new paragraph style to the > existing text, by setting it as the value for NSParagraphStyleAttributeName > on the text storage. To make this work well with the text view, you would > probably want to surround this with calls to shouldChange/didChange > methods--take a look at some of the samples for code examples of this sort of > thing. > > Douglas Davidson > > -- Lyndsey Ferguson _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com