• 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
Font Color In CTLineDraw?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Font Color In CTLineDraw?


  • Subject: Font Color In CTLineDraw?
  • From: Mike Rossetti <email@hidden>
  • Date: Tue, 02 Sep 2008 20:43:40 -0600

Are there limitations on what kind of text can be drawn using CTLineDraw in a Quartz context? I'm finding it impossible to set the font color.

Here is some code I've been experimenting with:

 ...
 NSFontDescriptor *fontDesc
   = [NSFontDescriptor fontDescriptorWithFontAttributes:
      [NSDictionary dictionaryWithObjectsAndKeys:
       @"American Typewriter", NSFontFamilyAttribute,
       @"Light", NSFontFaceAttribute,
       nil]];

 NSFont *font = [NSFont fontWithDescriptor:fontDesc
                                      size:24.0];
 NSDictionary* fontAttrs
   = [NSDictionary dictionaryWithObjectsAndKeys:
      font, NSFontAttributeName,
      [NSColor redColor], NSForegroundColorAttributeName, // No effect.
      nil];

NSMutableAttributedString* attrString
= [[NSMutableAttributedString alloc] initWithString:mainTitle
attributes:fontAttrs];
[attrString addAttribute:NSForegroundColorAttributeName
value:[NSColor lightGrayColor] // No effect.
range:NSMakeRange(0, [attrString length])];
CTLineRef line
= CTLineCreateWithAttributedString((CFAttributedStringRef)attrString);
CGContextSetTextPosition(ctx, 10.0, 10.0);
CTLineDraw(line, ctx);
CFRelease(line);
...


Neither of the color calls have any effect. I've also tried using the 'raw' CF approach but, as expected, it made no difference.

Thanks,
Mike
_______________________________________________

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: Font Color In CTLineDraw?
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: utf8 to NSString crasher
  • Next by Date: Re: NSTableView/NSOutlineView variable row height
  • Previous by thread: Re: utf8 to NSString crasher
  • Next by thread: Re: Font Color In CTLineDraw?
  • Index(es):
    • Date
    • Thread