• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
TextView font specification?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TextView font specification?


  • Subject: TextView font specification?
  • From: Jerry LeVan <email@hidden>
  • Date: Sat, 7 Feb 2004 14:31:24 -0500

Hi,

I am still trying to get the "BigSQL" program from BigNerdRanch squared away. I found a hang in this procedure,
it writes a colored string into outputTextView. The first time it is called nothing has been written into the view.

**********
- (void)appendToLog:(NSString *)s color:(NSColor *)c
{
//return ; // jhl
NSFont *font = [outputTextView font];
NSLog(@"font: %@", font);
NSRange r;
NSTextStorage *ts = [outputTextView textStorage];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:c forKey:NSForegroundColorAttributeName];
[dict setObject:font forKey:NSFontAttributeName];
NSAttributedString *toAdd = [[NSAttributedString alloc] initWithString:s attributes:dict];
[dict release];
[ts appendAttributedString:toAdd];
[toAdd release];
r.location = [ts length];
r.length = 0;
[outputTextView scrollRangeToVisible:r];
[outputTextView display];
}
*********

The first statement returns null for font and not the default Courier 12! This causes the statement
[dict setObject:font forKey:NSFontAttributeName] statement to fail. My workaround was to set the font for
"outputTextView" explicitly in the AwakeFromNib routine.

Is there a way to set the font in the view from IB?

The supplied source code is pre Xcode and does compile and work. When the supplied nib is updated to 10.2 the font problem rears its ugly head...

Thanks,

--Jerry
_______________________________________________
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.

  • Prev by Date: Re: Weird Threads
  • Next by Date: Re: NSSavePanel, background-only app, "Replace?" alert ordering
  • Previous by thread: Re: Weird Threads
  • Next by thread: NSSlider and live resize
  • Index(es):
    • Date
    • Thread