Font Color In CTLineDraw?
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