• 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
Attributes set in NSTextStorage ignored/overridden
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Attributes set in NSTextStorage ignored/overridden


  • Subject: Attributes set in NSTextStorage ignored/overridden
  • From: Dale Miller <email@hidden>
  • Date: Mon, 29 Mar 2010 10:12:59 -0700

I am attempting to display information in an NSTextView. The information is added line-by-line with some lines to be displayed in bold font and underlined, while other lines are to be displayed normally. I add each line as follows:
tstor = [textView textStorage];
[tstor beginEditing];
[tstor appendAttributedString:[[NSAtttributedString alloc]
initWithString: --- (NSString) ---
attributes:stext]]; /* or "btext" for the bold,underlined text */
[tstor endEditing];
After adding the first line which should be in bold/underline, NSLog(@"tstor = %@",tstor) shows the following:
tstor = NWISSysInit:00001
{
"BitstreamVeraSansMono-Bold 9.00 pt. P [] (0x001922e0) fobj=0x0018a180, spc=5.42" = NSFont;
1 = NSUnderline;
NSFont = "Helvetica 12.00 pt. P [] (0x00192300) fobj=0x00150430, spc=3.33";
}
So, all my text comes out in Helvetica 12, no underline.
I have textview as editable, and as richText
Why is the underline ignored, and why is the font overridden? I don't understand the contradiction and the reversed syntax between the first and third line of the log of the text storage attributes.


I have two fonts:
sfont = [NSFont fontWithName:@"Bitstream Vera Sans Mono" size:9.0];
bfont = [NSFont fontWithName:@"Bitstream Vera Sans Mono Bold" size:9.0];

NSLog of the two fonts:
sfont = "BitstreamVeraSansMono-Roman 9.00 pt. P [] (0x0018a470) fobj=0x00189e20, spc=5.42"
bfont = "BitstreamVeraSansMono-Bold 9.00 pt. P [] (0x0018a470) fobj=0x0018a180, spc=5.42"

two attribute dictionaries:
stext = [[NSDictionary alloc]initWithObjectsAndKeys:
NSFontAttributeName,sfont,
NSUnderlineStyleAttributeName,[NSNumber numberWithInt:NSUnderlineStyleNone],
nil];
btext = [[NSDictionary alloc]initWithObjectsAndKeys:
NSFontAttributeName,bfont,
NSUnderlineStyleAttributeName,[NSNumber numberWithInt:NSUnderlineStyleSingle],
nil];
NSLog of the two dictionaries:
stext = {
"BitstreamVeraSansMono-Roman 9.00 pt. P [] (0x0018a470) fobj=0x00189e20, spc=5.42" = NSFont;
0 = NSUnderline;
}
btext = {
"BitstreamVeraSansMono-Bold 9.00 pt. P [] (0x0018a470) fobj=0x0018a180, spc=5.42" = NSFont;
1 = NSUnderline;
}


Dale Miller
email@hidden




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Attributes set in NSTextStorage ignored/overridden
      • From: Gideon King <email@hidden>
  • Prev by Date: "-forwardInvocation:" like NSInvocation creation
  • Next by Date: Re: Attributes set in NSTextStorage ignored/overridden
  • Previous by thread: Re: "-forwardInvocation:" like NSInvocation creation
  • Next by thread: Re: Attributes set in NSTextStorage ignored/overridden
  • Index(es):
    • Date
    • Thread